Integrated circuit package including programmable oscillators

ABSTRACT

An integrated circuit package includes a processing core and an internal oscillator. The processing core operates on a set of instructions to carry out predefined processes. The internal oscillator provides a system clock for the integrated circuit package. The internal oscillator has associated therewith an internal control register for controlling the operation of the internal oscillator responsive to control bits of the internal oscillator controlled by the processing core.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a Continuation of U.S. patent application Ser. No.11/618,644, filed Dec. 29, 2006, entitled “ANALOG-TO-DIGITAL CONVERTERWITH LOW POWER TRACK-AND-HOLD MODE”, which is a Continuation of U.S.patent application Ser. No. 09/885,459, filed Jun. 19, 2001 and entitled“FIELD PROGRAMMABLE MIXED-SIGNAL CIRCUIT”, which claims benefit ofProvisional Application No. 60/212,653, filed Jun. 19, 2000, entitled“FIELD PROGRAMMABLE MIXED-SIGNAL CIRCUIT” and is related to U.S. patentapplication Ser. No. 11/381,707, filed May 4, 2006, entitled “FIELDPROGRAMMABLE MIXED-SIGNAL CIRCUIT”, all of which are incorporated hereinby reference.

TECHNICAL FIELD OF THE INVENTION

The invention pertains in general to oscillators and, more particularlyto programmable oscillators.

BACKGROUND OF THE INVENTION

As integrated circuits have seen increased use in recent years, theintegration of multiple functions onto a single chip has also increased.Although purely digital circuits require a common technology withrespect to transistors, i.e., all CMOS transistors, analog circuitryrequires a different technology for such devices as bipolar devices.Each technology facilitates itself to a common processing technology forcommon devices when only that technology is involved and required.However, whenever audio systems are combined with digital systems,analog technology must be merged with digital technology. This cancreate problems due to the fact that analog circuitry is sometimesincompatible with the digital clocking signals, especially with respectto analog-to-digital converters. Very high resolution analog-to-digitalconverters or digital-to-analog converters can be affected by noisecreated in the digital circuitry. When merging the two technologiestogether, this is referred to as “mixed-signal” technology.

In current mixed-signal technology, it is desirable to combine thefunctionality of a microprocessor or microcontroller with an interfaceto the analog domain through an analog-to-digital converter or adigital-to-analog converter. Further, for many applications, there is adesire for configurability to allow various functions to be emulated orrealized with the circuit. Some instrumentation applications requiresuch. The application could be achieved with multiple integratedcircuits configured in many different ways, but the desire is for asingle chip solution.

SUMMARY OF THE INVENTION

The present invention, as disclosed and described herein, in one aspectthereof, comprises an integrated circuit package that includes aprocessing core for operating on a set of instructions to carry outpredefined processes. The package further includes an internaloscillator for providing a system clock for the integrated circuitpackage. An internal oscillator control register controls the operationof the internal oscillator responsive to control bits of the internaloscillator controlled by the processing core.

BRIEF DESCRIPTION OF THE DRAWINGS

For a more complete understanding of the present invention and theadvantages thereof, reference is now made to the following descriptiontaken in conjunction with the accompanying Drawings in which:

FIG. 1 illustrates an overall diagram of the system;

FIG. 2 illustrates in more detailed block diagram of the system;

FIG. 3 illustrates the onboard clock and reset;

FIG. 4 illustrates the onboard memory maps; and

FIG. 5 illustrates an emulation diagram;

FIG. 6 illustrates the digital crossbar;

FIG. 7 illustrates a PCA block diagram;

FIG. 8 illustrates the ADC;

FIG. 9 illustrates the comparator and DAC diagrams;

FIG. 10 illustrates the ADC;

FIGS. 11A and 11B illustrate a timing diagram for the ADC;

FIG. 12 illustrates a diagram for the temperature sensor;

FIGS. 13A, 13B, 14A and 14B illustrate the ADC inter operations;

FIG. 15 illustrates the DAC functional block diagram;

FIG. 16 illustrates the comparator diagram;

FIG. 17 illustrates the comparator hysteresis plot;

FIG. 18 illustrates a voltage reference functional block diagram;

FIG. 19 illustrates a block diagram of the microcontroller core;

FIG. 20 illustrates a memory map;

FIG. 21 illustrates a diagrammatic view of the flash program memorybytes;

FIG. 22 illustrates a plot of the V_(DD) monitor timing diagram;

FIG. 23 illustrates a block diagram of the oscillator.

FIG. 24 illustrates a diagram of the Port I/O Cell;

FIGS. 25A and 25B illustrate a diagram of the SMBUS;

FIG. 26 illustrates a configuration for the SMBUS;

FIG. 27 illustrates a diagram of an SMBUS transaction;

FIG. 28 illustrates a diagram of the SPI block diagram;

FIG. 29 illustrates a diagram of a typical SPI interconnection;

FIG. 30 illustrates a diagram of the full duplex operation;

FIG. 31 illustrates a diagram of the data clock timing diagram;

FIGS. 32A and 32B illustrates a diagram of the UART;

FIGS. 33, 34 and 35 illustrate diagrams for the UART diagrams;

FIG. 36 illustrates a diagram for interconnects for the UART;

FIG. 37 illustrates a timing diagram for the UART;

FIG. 38 illustrates and interconnect diagram for the UART;

FIGS. 39-44 illustrates block diagrams for the T0 and T1 modes;

FIG. 45 illustrates a block diagram of the Timer; and

FIGS. 46-51 illustrates diagrams for the various PCA operational modes.

DETAILED DESCRIPTION OF THE INVENTION

System Overview

The integrated circuit is a fully integrated mixed-signal System on aChip with a true 12-bit multi-channel ADC 10 with a programmable gainpre-amplifier 12, two 12-bit DACs 14 and 16, two voltage comparators 18and 20, a voltage reference 22, and an 8051-compatible microcontrollercore 24 with 32 kbytes of FLASH memory 26. There are also I2C/SMBUS 28,UART 30, and SPI 32 serial interfaces implemented in hardware (not“bit-banged” in user software) as well as a Programmable Counter/TimerArray (PCA) 34 with five capture/compare modules. There are also 32general purpose digital Port I/O.

With an on-board VDD monitor 36, WDT, and clock oscillator 37, theintegrated circuit is a stand-alone System on a Chip. The MCUeffectively configures and manages the analog and digital peripherals.The FLASH memory 26 can be reprogrammed even in-circuit, providingnon-volatile data storage, and also allowing field upgrades of the 8051firmware. The MCU can also individually shut down any or all of theperipherals to conserve power.

A JTAG interface 38 allows the user to interface with the IC. On-boardJTAG emulation support allows non-intrusive (uses no on-chip resources),full speed, in-circuit emulation using the production integrated circuitinstalled in the final application. This emulation system supportsinspection and modification of memory and registers, settingbreakpoints, watchpoints, single stepping, run and halt commands. Allanalog and digital peripherals are fully functional when emulating usingJTAG.

CIP-51™ Microcontroller Core

The integrated circuit utilizes a microcontroller core 40. Themicrocontroller 40 is fully compatible with the MCS-51™ instruction set.Standard 803x/805x assemblers and compilers can be used to developsoftware. The core has all the peripherals included with a standard8052, including three 16-bit counter/timers, a full-duplex UART, 256bytes of internal RAM, 128 byte Special Function Register (SFR) addressspace, and four byte-wide I/O Ports.

FIG. 1 illustrates a block diagram of the integrated circuit of thepresent disclosure. The core is interfaced through and internal BUS 50to the various input/output blocks. A cross-bar switch 52, whichcross-bar switch 52 which will be described hereinbelow, provides aninterface between the IR 30, SPI BUS 32, etc., and the digital I/Ooutput. This is a configurable interface. That can be associated withthe VDD monitor 36.

The Microcontroller 40 employs a pipelined architecture that greatlyincreases its instruction throughput over the standard 8051architecture. In a standard 8051, all instructions except for MUL andDIV take 12 or 24 system clock cycles to execute with a maximum systemclock of 12 MHz. By contrast, the Microcontroller 40 core executesseventy percent (70%) of its instructions in one or two system clockcycles, with only four instructions taking more than four system clockcycles. The Microcontroller 40 has a total of 109 instructions. Thenumber of instructions versus the system clock cycles to execute them isas follows: Instructions 26 50 5 14 7 3 1 2 1 Clocks to Execute 1 2 2/33 3/4 4 4/5 5 8

With the Microcontroller 40's maximum system clock at 20 MHz, it has apeak throughput of 20 MIPS.

Referring now to FIG. 3, there is illustrated a more detailed diagram ofthe clock and resent function. The integrated circuit has severalfeatures both inside and outside the Microcontroller 40 core to improveits overall performance and ease of use in the end applications.

An extended interrupt handler 100 provides 22 interrupt sources into theMicrocontroller 40 (as opposed to 7 for the standard 8051), allowing thenumerous analog and digital peripherals to interrupt the controller. Aninterrupt driven system requires less intervention by the MCU, giving itmore effective throughput. The extra interrupt sources are very usefulwhen building multi-tasking, real-time systems.

There are up to seven reset sources for the system the on-board V_(DD)monitor 36, a Watchdog Timer (WDT), a missing clock detector 104, avoltage level detection from a Comparator 0, a forced software reset online 114, and two external reset pins 109. The /RST pin 54 isbi-directional, accommodating an external reset, or allowing theinternally generated reset to be output on the /RST pin 54. Each resetsource except for the V_(DD) monitor and Reset Input Pin may be disabledby the user in software. The WDT 102 may be permanently enabled insoftware after a power-on reset during MCU initialization. All of thesources are wired Ored with OR circuit 120 to provide a system reset oninput 122 to microcontroller 40.

The system has an internal, stand alone clock generator 112 which isused by default as the system clock after any reset. If desired, theclock source may be switched on the fly to the external oscillator 37,which can use a crystal, ceramic resonator, capacitor, RC, or externalclock source to generate the system clock. This can be extremely usefulin low power applications, allowing the system to run from a slow (powersaving) external crystal source, while periodically switching to thefast (up to 15 MHz) internal oscillator as needed.

Memory

The Microcontroller 40 has a standard 8051 program and data addressconfiguration. It includes 256 bytes of data RAM, with the upper 128bytes dual-mapped. Indirect addressing accesses the upper 128 bytes ofgeneral purpose RAM, and direct addressing accesses the 128 byte SFRaddress space. The lower 128 bytes of RAM are accessible via direct andindirect addressing. The first 32 bytes are addressable as four banks ofgeneral purpose registers, and the next 16 bytes can be byte addressableor bit addressable.

The integrated circuit program memory consists of 32 k+128 bytes ofFLASH in memory 26. This memory 26 may be reprogrammed in-system in 512byte sectors, and requires no special off-chip programming voltage. The512 bytes from addresses 0x7E00 to 0x7FFF are reserved for factory use.There is also a single 128-byte sector at address 0x8000 to 0x807F,which may be useful as a small table for software constants or asadditional program space. See 4 for the system memory map.

JTAG Emulation and Boundary Scan

Referring now to FIG. 5, there is illustrated a block diagram of theJTAG emulation. The integrated circuit has on-chip JTAG and emulationlogic that provide non-intrusive, full speed, in-circuit emulation usingthe production part installed in the end application using the four-pinJTAG I/F. The JTAG port is fully compliant to IEEE 1149.1, providingfull boundary scan for test and manufacturing purposes.

An emulation system is provided that supports inspection andmodification of memory and registers, breakpoints, watchpoints, a stackmonitor, and single stepping. No additional target RAM, program memory,timers, or communications channels are required. All the digital andanalog peripherals are functional and work correctly while emulating.All the peripherals (except for the ADC) are stalled when the MCU ishalted, during single stepping, or at a breakpoint in order to keep themin sync.

A development software application 202 is provided with an emulationinterface 200 to develop application code and perform in-circuitemulation with the integrated circuit. The software includes adeveloper's studio and debugger, and an integrated 8051 assembler. Atarget application board 204 is provided with a integrated circuitinstalled and large prototyping area, plus an RS-232 cable 208 and JTAGcable 210, and wall-mount power supply. The Development Kit requires aWindows 95/98 or NT computer with one available RS-232 serial port. A PC214 is connected via the RS-232 cable 208 to the Emulation Cartridge200. A six-inch ribbon cable connects the Emulation Cartridge 200 to theuser's application board 204, picking up the four JTAG pins and V_(DD)and GND. The Emulation Cartridge 200 takes its power from theapplication board. It requires roughly 20 mA at 2.7-3.6V. Forapplications where there is not sufficient power available from thetarget board 204, the provided power supply can be connected directly tothe Emulation Cartridge 200.

Programmable Digital I/O and Crossbar

Referring now to FIG. 6, there is illustrated a block diagram of thedigital cross-bar 52. The standard 8051 Ports (0, 1, 2, and 3) areavailable on the system. The Port I/O behave like the standard 8051 witha few enhancements. Each Port I/O pin can be configured as either apush-pull or open-drain output. Also, the “weak pull-ups” which arenormally fixed on an 8051 can be globally disabled, providing additionalpower saving capabilities for low power applications. The DigitalCrossbar 52 is essentially a large digital switching network that allowsmapping of internal digital system resources to Port I/O pins on P0, P1,and P2. Unlike microcontrollers with standard multiplexed digital I/O,all combinations of functions are supported.

The on-board counter/timers, serial buses, HW interrupts, ADC Start ofConversion input, comparator outputs, and other digital signals in thecontroller 52 can be configured to appear on the Port I/O pins specifiedin Crossbar Control registers 402. This allows the user to select theexact mix of general purpose Port I/O and digital resources needed forhis particular application.

The digital cross-bar 52 has a priority decoder 402 that is associatedtherewith. The lowest priority group that can be interfaced with are theSMBUS 28, SPI 32, UART 30, PCA 34, the T0, T1 and T2 block 406 andgeneral miscellaneous computer outputs 410. Additionally, there are theport latches which are interfaced through lines 412 to the cross-bar 52.

The I/O side is interfaced to BUSes 414, 416 and 418, respectively, allnetworked for each of the cell 420 interfaces with eight external pins,such that there are three banks of pins. They range from the highestpriority at Port 0 associated with the cell one 420 to the lowestpriority associated with the cell 424. There is also provided a fourthport cell 426, associated with a second set of eight outputs. These aredirectly interfaced to the port latches. The detailed description ofdigital cross-bar 52 is described in U.S. patent application Ser. No.09/583,260, filed May 31, 2000, entitled CROSSBAR MATRIX FOR CONNECTINGDIGITAL RESOURCES TO I/O PINS OF AN INTEGRATED CIRCUIT, which isincorporated herein by reference.

Programmable Counter Array

Referring now to FIG. 7, there is illustrated a block diagram of theon-board Programmable Counter/Timer Array (PCA) 34 in addition to thefour counter/timers included with the 8051. The PCA consists of adedicated 16-bit counter/timer time base with five programmablecapture/compare modules 502-510. The timebase receives its clock fromone of four sources: the system clock divided by 12 through a divider512, the system clock divided by four through a timer 514, Timer 0overflow, or an External Clock Input (ECI) on line 516.

Each capture/compare module 502-510 can be configured to operate in oneof four modes: Edge-Triggered Capture, Software Timer, High SpeedOutput, or Pulse Width Modulator. The PCA Capture/Compare Module I/O andExternal Clock Input are routed to the integrated circuit Port I/O viathe Digital Crossbar.

Serial Ports

The integrated circuit, as described hereinabove, includes a Full-DuplexUART, SPI BUS, and I2C/SMBUS. Each of the serial buses is fullyimplemented in hardware and makes extensive use of the Microcontroller40's interrupts, thus requiring very little intervention by the CPU. Theserial buses do not “share” resources such as timers, interrupts, orPort I/O, so any or all of the ports may be used together or separatelywith any other.

Analog to Digital Converter

Referring now to FIG. 8, there is illustrated a block diagram of the ADCintegrated circuit which has an on-board 12-bit SAR ADC 10 with a9-channel input multiplexer 550 and programmable gain amplifier 12. Witha maximum throughput of 100 ksps, the ADC offers true 12-bit accuracywith an INL of ±1LSB. There is also an on-board 30 ppm voltagereference, which can be overridden externally.

The ADC 10 is under full control of the Microcontroller 40 via theSpecial Function Registers. One input channel is tied to an internaltemperature sensor 552, while the other eight channels are availableexternally through pins 556. Each pair of the eight external inputchannels can be configured as either two single-ended inputs or a singledifferential input. The system controller can also put the ADC 10 intoshutdown to save power.

The programmable gain amplifier 12 follows the analog multiplexer 550.The gain can be set in software from 0.5 to 16 in powers of 2. The gainstage can be especially useful when different ADC input channels havewidely varied input voltage signals, or when it is necessary to “zoomin” on a signal with a large DC offset (in differential mode, a DACcould be used to provide the DC offset).

Conversions can be started in four ways; a software command, an overflowon Timer 2, an overflow on Timer 3, or an external signal input. Thisflexibility allows the start of conversion to be triggered by softwareevents, external HW signals, or convert continuously. A completedconversion causes an interrupt, or a status bit can be polled insoftware to determine the end of conversion. The resulting 12-bit dataword is latched into two SFRs upon completion of a conversion. The datacan be right or left justified in these registers under softwarecontrol.

Compare registers for the ADC data can be configured to interrupt thecontroller when ADC data is within a specified window. The ADC canmonitor a key voltage continuously in background mode, but not interruptthe controller unless the converted data is within the specified window.The ADC is described in U.S. patent application Ser. No. 09/595,959,filed Jun. 19, 2000, and entitled DIFFERENTIAL/SINGLE ENDEDANALOG-TO-DIGITAL CONVERTER (Atty. Dkt No. CYGL-24,695), and in U.S.patent application Ser. No. 09/638,095, filed Aug. 11, 2000, entitledPROGRAMMABLE GAIN ADC, (ATTY Dkt. CYGL-25,367) and in U.S. patentapplication Ser. No. 09/637,493, filed Aug. 11, 2000, and entitledCOMPARATOR-AMPLIFIER CONFIGURATION IN AN ADC (Atty. Dkt. No.CYGL-25,368), and in U.S. patent Ser. No. 09/419,148, filed Oct. 15,1999, and entitled A/D CONVERTER WITH VOLTAGE/CHARGE SCALING (Atty. Dkt.No. CYGL-24,686), all of which are incorporated herein by reference.

Comparators and DACs

Referring now to FIG. 10, there is illustrated a block diagram of theComparator/DAC function. The integrated circuit has two 12-bit DACs 14and 16 and two comparators 18 and 20 on chip. The MCU data and controlinterface to each comparator and DAC is via Special Function Registers600. The MCU can place any DAC or comparator in low power shutdown mode.The comparators have software programmable hysteresis. Each comparatorcan generate an interrupt on its rising edge, falling edge, or both. Thecomparators' output state can also be polled in software. Theseinterrupts are capable of waking up the MCU from sleep mode. Thecomparator outputs can be programmed to appear on the Port I/O pins viathe Crossbar 52.

The DACs are voltage output mode and use the same voltage reference asthe ADC 10. They are especially useful as references for the comparatorsor offsets for the differential inputs of the ADC 10. The operation ofthe DACs 14 and 16 is described in U.S. patent application Ser. No.09/583,341, filed May 31, 2000, and entitled SEGMENTED D/A CONVERTERWITH ENHANCED DYNAMIC RANGE (Atty. Dkt No. CYGL-24,999), and in U.S.patent application Ser. No. 09/584,311, filed May 31, 2000, and entitledD/A CONVERTER STREET EFFECT COMPENSATION, (Atty. DKT No. CV6L-24,154),all of which are incorporated herein by reference.

Pinout and Package Definitions

The following are the pin definitions for various configurations. PinDefinitions ‘F0 ‘F0 ‘F0 00 01 02 64- 48- 32- Name Pin Pin Pin TypeDescription V_(DD)  31,  23,  18, Digital Voltage Supply.  40, 32 20 62DGND  30,  22,  17, Digital Ground.  41,  33, 21 61  27, 19 AV+  16, 13,  9, Positive Analog Voltage Supply. 17 43 29 AGND  5,  44,  8,Analog Ground. 15 12 30 TCK 22 18 14 D In JTAG Test Clock with internalpull-up. TMS 21 17 13 D In JTAG Test-Mode Select with internal pull-up.TDI 28 20 15 D In JTAG Test Data Input with internal pull-up. TDI islatched on a rising edge of TCK. TDO 29 21 16 D Out JTAG Test DataOutput. Data is shifted out on TDO on the falling edge of TCK. TDOoutput is a tri-state driver. XTAL1 18 14 10 D In Crystal Input. Thispin is the return for the internal oscillator circuit for a crystal orceramic resonator. For a precision internal clock, connect a crystal orceramic resonator from XTAL1 to XTAL2. If overdriven by an external CMOSclock, this becomes the system clock. XTAL2 19 15 11 D Out CrystalOutput. This pin is the excitation driver for a crystal or ceramicresonator. /RST 20 16 12 D I/O Chip Reset. Open-drain output of internalVoltage Supply monitor. Is driven low when VDD is < 2.7V. An externalsource can force a system reset by driving this pin low. VREF 6 3 3 AI/O Voltage Reference. When configured as an input, this pin is thevoltage reference for the MCU. Otherwise, the internal reference drivesthis pin. CP0+ 4 2 2 A In Comparator 0 Non-Inverting Input. CP0− 3 1 1 AIn Comparator 0 Inverting Input. CP1+ 2 45 A In Comparator 1Non-Inverting Input. CP1− 1 46 A In Comparator 1 Inverting Input. DAC064 48 32 A Out Digital to Analog Converter Output 0. The DAC0 voltageoutput. (See Section_Ref473612034˜DAC Specification for completedescription). DAC1 63 47 31 A Out Digital to Analog Converter Output 1.The DAC1 voltage output. (See Section_Ref473612034·DAC Specification forcomplete description). AIN0 7 4 4 A In Analog Mux Channel Input 0. (SeeSection _Ref483109445·ADC Specification for complete description). AIN18 5 5 A In Analog Mux Channel Input 1. (See Section _Ref483109445·ADCSpecification for complete description). AIN2 9 6 6 A In Analog MuxChannel Input 2. (See Section _Ref483109445·ADC Specification forcomplete description). AIN3 10 7 7 A In Analog Mux Channel Input 3. (SeeSection _Ref483109445·ADC Specification for complete description). AIN411 8 A In Analog Mux Channel Input 4. (See Section _Ref483109445·ADCSpecification for complete description). AIN5 12 9 A In Analog MuxChannel Input 5. (See Section _Ref483109445·ADC Specification forcomplete description). AIN6 13 10 A In Analog Mux Channel Input 6. (SeeSection _Ref483109445·ADC Specification for complete description). AIN714 11 A In Analog Mux Channel Input 7. (See Section _Ref483109445·ADCSpecification for complete description). P0.0 39 31 19 DI/O Port0 Bit0.P0.1 42 34 22 DI/O Port0 Bit1. P0.2 47 35 23 DI/O Port0 Bit2. P0.3 48 3624 DI/O Port0 Bit3. P0.4 49 37 25 DI/O Port0 Bit4. P0.5 50 38 26 DI/OPort0 Bit5. P0.6 55 39 27 DI/O Port0 Bit6. P0.7 56 40 28 DI/O Port0Bit7. P1.0 38 30 DI/O Port1 Bit0. P1.1 37 29 DI/O Port1 Bit1. P1.2 36 28DI/O Port1 Bit2. P1.3 35 26 DI/O Port1 Bit3. P1.4 34 25 DI/O Port1 Bit4.P1.5 32 24 DI/O Port1 Bit5. P1.6 60 42 DI/O Port1 Bit6. P1.7 59 41 DI/OPort1 Bit7. P2.0 33 DI/O Port2 Bit0. P2.1 27 DI/O Port2 Bit1. P2.2 54DI/O Port2 Bit2. P2.3 53 DI/O Port2 Bit3. P2.4 52 DI/O Port2 Bit4. P2.551 DI/O Port2 Bit5. P2.6 44 DI/O Port2 Bit6. P2.7 43 DI/O Port2 Bit7.P3.0 26 DI/O Port3 Bit0. P3.1 25 DI/O Port3 Bit1. P3.2 24 DI/O Port3Bit2. P3.3 23 DI/O Port3 Bit3. P3.4 58 DI/O Port3 Bit4. P3.5 57 DI/OPort3 Bit5. P3.6 46 DI/O Port3 Bit6. (See the Port I/O Sub-Systemsection for complete description). P3.7 45 DI/O Port3 Bit7. (See thePort I/O Sub-System section for complete description).Analog to Digital Converter

Referring now to FIG. 10, there is illustrated a more detailed diagramof the ADC 10. The ADC subsystem consists of the 9-channel, configurableanalog multiplexer (AMUX) 350, the programmable gain amplifier (PGA) 12,and a 100 ksps, 12-bit successive-approximation-register ADC withintegrated track-and-hold and programmable window detector. The AMUX,PGA, Data Conversion Modes, and Window Detector are all configurableunder software control via the Special Function Register's 610. The ADCsubsystem (ADC, track-and-hold and PGA) is enabled only when the ADCENbit in the ADC Control register (ADC0CN) is set to 1 as illustrated intiming diagrams in FIGS. 11A and 11B. The ADC subsystem is in low powershutdown when this bit is 0.

Analog Multiplexer and PGA

Eight of the AMUX channels are available for external measurements whilethe ninth channel is internally connected to an on-board temperaturesensor 552 (temperature transfer function is shown in FIGS. 13A and13B). AMUX input pairs can be programmed to operate in either thedifferential or single-ended mode. This allows the user to select thebest measurement technique for each input channel, and even accommodatesmode changes “on-the-fly”. The AMUX defaults to all single-ended inputsupon reset. There are two registers associated with the AMUX: a ChannelSelection register AMX0SL 612, and a Configuration register AMX0CF 614.Table 2 shows AMUX functionality by channel, for each possibleconfiguration with Table 3 illustrating the AMX0CF functionality. ThePGA 12 amplifies the AMUX output signal by an amount determined by thestates of the AMPGN2-0 bits in the ADC Configuration register, ADC0CF,illustrated in Table 4. The PGA can be software-programmed for gains of0.5, 2, 4, 8 or 16. It defaults to unity gain on reset.

ADC Modes of Operation

The ADC has a maximum conversion speed of 100 ksps. The ADC conversionclock is derived from the system clock. Conversion speed can be reducedby a factor of 2, 4, 8 or 16 via the ADCSC bits in the ADC0CF Register616. This is useful to adjust conversion speed to accommodate differentsystem clock speeds.

A conversion can be initiated in one of four ways, depending on theprogrammed states of the ADC Start of Conversion Mode bits (ADSTM1,ADSTM0) in an ADC0CN register 618. Conversions may be initiated by:

Writing a 1 to the ADBUSY bit of ADC0CN;

A Timer 3 overflow (i.e. timed continuous conversions);

A rising edge detected on the external ADC convert start signal, CNVSTR;

A Timer 2 overflow (i.e. timed continuous conversions).

Writing a 1 to ADBUSY provides software control of the ADC wherebyconversions are performed “on-demand”. During conversion, the ADBUSY bitis set to 1 and restored to 0 when conversion is complete. The fallingedge of ADBUSY triggers an interrupt (when enabled) and sets theinterrupt flag in ADC0CN. Converted data is available in the ADC dataword MSB and LSB registers, ADC0H, ADC0L. Converted data can be eitherleft or right justified in the ADC0H:ADC0L register pair depending onthe programmed state of the ADLJST bit in the ADC0CN register. This isillustrated in Table 5.

The ADCTM bit in register ADC0CN 618 controls the ADC track-and-holdmode. In its default state, the ADC input is continuously tracked,except when a conversion is in progress. Setting ADCTM to 1 allows oneof four different low power track-and-hold modes to be specified bystates of the ADSTM1-0 bits (also in ADC0CN):

Tracking begins with a write of 1 to ADBUSY and lasts for 3 SAR clocks;

Tracking starts with an overflow of Timer 3 and lasts for 3 SAR clocks;

Tracking is active only when the CNVSTR input is low;

Tracking starts with an overflow of Timer 2 and lasts for 3 SAR clocks.

Modes 1, 2 and 3 (above) are useful when the start of conversion istriggered in software command or when the ADC is operated continuously.Mode 4 is used when the start of conversion is triggered by externalhardware. In this case, the track-and-hold is in its low power mode attimes when the CNVSTR input is high. Tracking can also be disabled(shutdown) when the entire chip is in low power standby or sleep modes.

ADC Programmable Window Detector

The ADC programmable window detector is very useful in manyapplications. It continuously compares the ADC output to user-programmedlimits and notifies the system when an out-of-band condition isdetected. This is especially effective in an interrupt-driven system,saving code space and CPU bandwidth while delivering faster systemresponse times. The window detector interrupt flag (ADWINT in ADC0CN)can also be used in polled mode. The high and low bytes of the referencewords are loaded into the ADC Greater-Than and ADC Less-Than registers(ADC0GTH, ADC0GTL, ADC0LTH, and ADC0LTL). FIGS. 13A, 13B, 14A and 14Bshow example comparisons for reference. Notice that the window detectorflag can be asserted when the measured data is inside or outside theuser-programmed limits, depending on the programming of the ADC0GTx andADC0LTx registers.

DACs 12 Bit Voltage Mode

Referring now to FIG. 15, there is illustrated a clock diagram of theDAC section. The MCU has two 12-bit voltage-mode Digital to AnalogConverters 14 and 16. Each DAC has an output swing of 0V to VREF-1LSBfor a corresponding input code range of 0x000 to 0xFFF. Using DAC0 14 asan example, the 12-bit data word is written to the low byte (DAC0L) andhigh byte (DAC0H) data registers 650 and 652. Data is latched into DAC0after a write to the corresponding DAC0H register, so the write sequenceshould be DAC0L followed by DAC0H if the full 12-bit resolution isrequired. The DAC can be used in 8-bit mode by initializing DAC0L to thedesired value (typically 0x00), and writing data to only DAC0H. DAC0Control Register (DAC0CN) 654 provides for enabling/disabling DAC0 andto modify its input data formatting.

The DAC0 enable/disable function is controlled by the DAC0EN bit(DAC0CN.7). Writing a 1 to DAC0EN enables DAC0 while writing a 0 toDAC0EN disables DAC0 with switch 656. While disabled, the output of DAC0is maintained in a high-impedance state, and the DAC0 supply currentfalls to 1 uA or less.

In some instances, input data should be shifted prior to a DAC0 writeoperation to properly justify data within the DAC input registers. Thisaction would typically require one or more load and shift operations,adding software overhead and slowing DAC throughput. To alleviate thisproblem, the data-formatting feature provides a means for the user toprogram the orientation of the DAC0 data word within data registersDAC0H and DAC0L. The three DAC0DF bits (DAC0CN[2:0]) allow the user tospecify one of five data word orientations as shown in the DAC0CNregister definition.DAC1 is functionally the same as DAC0 describedabove. DAC1 is functionally the same as DAC0 described above in Tables8-13.

Comparators

Referring now to FIG. 16, there is illustrated a block diagram of thecomparator section. The MCU has two on-board voltage comparators 18 and20. The inputs of each Comparator are available at the package pins. Theoutput of each comparator is optionally available at the package pinsvia the I/O crossbar 52. When assigned to package pins, each comparatoroutput can be programmed to operate in open drain or push-pull modes.

The hysteresis of each comparator is software-programmable via itsrespective Comparator control register (CPT0CN 660, CPT1CN 662). Theuser can program both the amount of hysteresis voltage (referred to theinput voltage) and the positive and negative-going symmetry of thishysteresis around the threshold voltage. The output of the comparatorcan be polled in software, or can be used as an interrupt source. Eachcomparator can be individually enabled or disabled (shutdown). Whendisabled, the comparator output (if assigned to a Port I/O pin via theCrossbar) defaults to the logic low state, its interrupt capability issuspended and its supply current falls to less than 1 uA. Comparator 0inputs can be externally driven from −0.25V to (AV+)+0.25V withoutdamage or upset.

The Comparator 0 hysteresis is programmed using bits 3-0 in theComparator 0 Control Register CPT0CN (shown in Table 11). The amount ofnegative hysteresis voltage is determined by the settings of the CP0HYNbits. As shown in FIG. 18, settings of 20, 10 or 5 mV of negativehysteresis can be programmed, or negative hysteresis can be disabled. Ina similar way, the amount of positive hysteresis is determined by thesetting the CP0HYP bits.

Comparator interrupts can be generated on both rising-edge andfalling-edge output transitions. (For Interrupt enable and prioritycontrol, see Section _Ref472925230˜). The CP0FIF flag is set upon aComparator 0 falling-edge interrupt, and the CP0RIF flag is set upon theComparator 0 rising-edge interrupt. Once set, these bits remain setuntil cleared by the CPU. The Output State of Comparator 0 can beobtained at any time by reading the CP0OUT bit. Comparator 0 is enabledby setting the CP0EN bit, and is disabled by clearing this bit.Comparator 0 can also be programmed as a reset source.

The operation of Comparator 1 is identical to that of Comparator 0,except the Comparator 1 is controlled by the CPT1CN Register as setforth in Table 12. Also, Comparator 1 can not be programmed as a resetsource.

Voltage Reference

Referring now to FIG. 18, the voltage reference circuit consists of a1.2V, 30 ppm/° C. (typical) bandgap voltage reference generator and again-of-two output buffer amplifier. The reference voltage on VREF canbe connected to external devices in the system, as long as the maximumload seen by the VREF pin is less than 10 uA to AGND.

If a different reference voltage is required, an external reference 672can be connected to the VREF pin and the internal bandgap and bufferamplifier disabled in software. The external reference voltage muststill be less than AV+−0.3V. A Reference Control Register 676, REF0CN(defined in Table 13), provides for enabling or disabling the bandgapand buffer amplifier 670. The BIASE bit in REF0CN enables the on-boardbandgap reference while the REFBE bit enables the buffer amplifier 670which drives the VREF pin. When disabled, the supply current drawn bythe bandgap and buffer amplifier falls to less than 1 uA (typical) andthe output of the buffer amplifier 670 enters a high impedance state. Ifthe internal bandgap is used as the reference voltage generator, BIASEand REFBE must both be set to 1. If an external reference 674 is used,REFBE must be set to 0 and BIASE must be set to 1. If neither the ADCnor the DAC are being used, both of these bits can be set to 0 toconserve power.

The temperature sensor connects to the highest order input of the A/Dconverter's input multiplexer. The TEMPE bit within REF0CN enables anddisables the temperature sensor. While disabled, the temperature sensordefaults to a high impedance state and any A/D measurements performed onthe sensor while disabled result in meaningless data.

Microcontroller

Referring now to FIG. 19, there is illustrated a block diagram of theMicrocontroller 40. The MCU's system controller core is theMicrocontroller 40. The Microcontroller 40 is fully compatible with theMCS-51™ instruction set. Standard 803x/805x assemblers and compilers canbe used to develop software. The MCU has a superset of all theperipherals included with a standard 8051. Included are four 16-bitcounter/timers, a full-duplex UART, 256 bytes of internal RAM 680, 128byte Special Function Register (SFR) address space, and four byte-wideI/O Ports. The Microcontroller 40 also includes on-chip emulationhardware, and interfaces directly with the MCU's analog and digitalsubsystems providing a complete data acquisition or control-systemsolution in a single integrated circuit.

Features

The Microcontroller 40 core implements the standard 8051 organizationand peripherals as well as additional custom peripherals and functionsto extend its capability. The Microcontroller 40 includes the followingfeatures:

-   -   Fully Compatible with MCS-51 Instruction Set    -   20 MIPS Peak Throughput with 20 MHz Clock    -   0 to 20 MHz Clock Frequency    -   256 Bytes of Internal RAM    -   32 k Byte Flash Program Memory    -   Four Byte-Wide I/O Ports    -   Extended Interrupt Handler    -   Reset Input    -   Power Management Modes    -   On-chip Emulation Logic    -   Program and Data Memory Security        Performance

The Microcontroller 40 employs a pipelined architecture that greatlyincreases its instruction throughput over the standard 8051architecture. In a standard 8051, all instructions except for MUL andDIV take 12 or 24 system clock cycles to execute, and usually have amaximum system clock of 12 MHz. By contrast, the Microcontroller 40 coreexecutes seventy percent (70%) of its instructions in one or two systemclock cycles, with no instructions taking more than eight system clockcycles.

With the Microcontroller 40's maximum system clock at 20 MHz, it has apeak throughput of 20MIPS. The Microcontroller 40 has a total of 109instructions. The number of instructions versus the system clock cyclesrequired to execute them is as follows: Instructions 26 50 5 14 7 3 1 21 Clocks to Execute 1 2 2/3 3 3/4 4 4/5 5 8Programming and Debugging Support

A JTAG-based serial interface is provided for in-system programming ofthe Flash program memory and communication with on-chip emulationsupport logic. The reprogrammable Flash can also be read and changed asingle byte at a time by the application software using the MOVC andMOVX instructions. This feature allows program memory to be used fornon-volatile data storage as well as updating program code undersoftware control.

The on-chip emulation support logic facilitates full speed in-circuitdebugging, allowing the setting of hardware breakpoints and watchpoints, starting, stopping and single stepping through program execution(including interrupt service routines), examination of the program'scall stack, and reading/writing the contents of registers and memory.This method of on-chip emulation is completely non-intrusive andnon-evasive, requiring no RAM, Stack, timers, or other on-chipresources.

Instruction Set

The instruction set of the Microcontroller 40 System Controller is fullycompatible with the standard MCS-51™ instruction set. Standard 8051development tools can be used to develop software for theMicrocontroller 40. All Microcontroller 40 instructions are the binaryand functional equivalent of their MCS-51™ counterparts, includingopcodes, addressing modes and effect on PSW flags. However, instructiontiming is different than that of the standard 8051.

Instruction and CPU Timing

In many 8051 implementations, a distinction is made between machinecycles and clock cycles, with machine cycles varying from 2 to 12 clockcycles in length. However, the Microcontroller 40 implementation isbased solely on clock cycle timing. All instruction timings arespecified in terms of clock cycles.

Due to the pipelined architecture of the Microcontroller 40, mostinstructions execute in the same number of clock cycles as there areprogram bytes in the instruction. Conditional branch instructions takeone less clock cycle to complete when the branch is not taken as opposedto when the branch is taken. Table 14 illustrates the Instruction SetSummary for the Microcontroller 40, which includes the mnemonic, numberof bytes, and number of clock cycles for each instruction.

MOVX Instruction and Program Memory

The MOVX instruction is typically used to access external data memory.The Microcontroller 40 does not support external data or program memory.In the Microcontroller 40, the MOVX instruction accesses the on-chipprogram memory space implemented as re-programmable Flash memory. Thisfeature provides a mechanism for the Microcontroller 40 to updateprogram code and use the program memory space for non-volatile datastorage. TABLE 14 Microcontroller 40 Instruction Set Summary ClockMnemonic Description Bytes Cycles ARITHMETIC OPERATIONS ADD A, Rn Addregister to A 1 1 ADD A, direct Add direct byte to A 2 2 ADD A, @Ri Addindirect RAM to A 1 2 ADD A, #data Add immediate to A 2 2 ADDC A, Rn Addregister to A with carry 1 1 ADDC A, direct Add direct byte to A withcarry 2 2 ADDC A, @Ri Add indirect RAM to A with carry 1 2 ADDC A, #dataAdd immediate to A with carry 2 2 SUBB A, Rn Subtract register from Awith borrow 1 1 SUBB A, direct Subtract direct byte from A with borrow 22 SUBB A, @Ri Subtract indirect RAM from A with borrow 1 2 SUBB A, #dataSubtract immediate from A with borrow 2 2 INC A Increment A 1 1 INC RnIncrement register 1 1 INC direct Increment direct byte 2 2 INC @RiIncrement indirect RAM 1 2 DEC A Decrement A 1 1 DEC Rn Decrementregister 1 1 DEC direct Decrement direct byte 2 2 DEC @Ri Decrementindirect RAM 1 2 INC DPTR Increment Data Pointer 1 1 MUL AB Multiply Aand B 1 4 DIV AB Divide A by B 1 8 DA A Decimal Adjust A 1 1 LOGICALOPERATIONS ANL A, Rn AND Register to A 1 1 ANL A, direct AND direct byteto A 2 2 ANL A, @Ri AND indirect RAM to A 1 2 ANL A, #data AND immediateto A 2 2 ANL direct, A AND A to direct byte 2 2 ANL direct, #data ANDimmediate to direct byte 3 3 ORL A, Rn OR Register to A 1 1 ORL A,direct OR direct byte to A 2 2 ORL A, @Ri OR indirect RAM to A 1 2 ORLA, #data OR immediate to A 2 2 ORL direct, A OR A to direct byte 2 2 ORLdirect, #data OR immediate to direct byte 3 3 XRL A, Rn Exclusive-ORRegister to A 1 1 XRL A, direct Exclusive-OR direct byte to A 2 2 XRL A,Ri Exclusive-OR indirect RAM to A 1 2 XRL A, #data Exclusive-ORimmediate to A 2 2 XRL direct, A Exclusive-OR A to direct byte 2 2 XRLdirect, #data Exclusive-OR immediate to direct byte 3 3 CLR A Clear A 11 CPL A Complement A 1 1 RL A Rotate A left 1 1 RLC A Rotate A leftthrough carry 1 1 RR A Rotate A right 1 1 RRC A Rotate A right throughcarry 1 1 SWAP A Swap nibbles of A 1 1 DATA TRANSFER MOV A, Rn Moveregister to A 1 1 MOV A, direct Move direct byte to A 2 2 MOV A, @RiMove indirect RAM to A 1 2 MOV A, #data Move immediate to A 2 2 MOV Rn,A Move A to register 1 1 MOV Rn, direct Move direct byte to register 2 2MOV Rn, #data Move immediate to to register 2 2 MOV direct, A Move A todirect byte 2 2 MOV direct, Rn Move register to direct byte 2 2 MOVdirect, direct Move direct byte to direct 3 3 MOV direct, @Ri Moveindirect RAM to direct byte 2 2 MOV direct, #data Move immediate todirect byte 3 3 MOV @Ri, A Move A to indirect RAM 1 2 MOV @Ri, directMove direct byte to indirect RAM 2 2 MOV @Ri, #data Move immediate toindirect RAM 2 2 MOV DPTR, #data16 Load data pointer with 16-bitconstant 3 3 MOVC A, @A + DPTR Move code byte relative DPTR to A 1 3MOVC A, @A + PC Move code byte relative PC to A 1 3 MOVX A, @Ri Moveexternal data (8-bit address) to A 1 3 MOVX @Ri, A Move A to externaldata (16 bit address to A 1 3 MOVX A, @DPTR, Move external data (16-bitaddress) 1 3 MOVX @DPTR,A Move A to external data (16-bit address) 1 3PUSH direct Push direct byte onto stack 2 2 POP direct Pop direct bytefrom from stack 2 2 XCH A, Rn Exchange register with A 1 1 XCH A, directExchange direct byte with A 2 2 XCH A, @Ri Exchange indirect RAM with A1 2 XCHD A, @Ri Exchange low nibble of indirect RAM with A 1 2 BOOLEANMANIPULATION CLR C Clear carry 1 1 CLR bit Clear direct bit 2 2 SETB CSet carry 1 1 SETB bit Set direct bit 2 2 CPL C Complement carry 1 1 CPLbit Complement direct bit 2 2 ANL C, bit AND direct bit to carry 2 2 ANLC, /bit AND complement of direct bit to carry 2 2 ORL C, bit OR directbit to carry 2 2 ORL C, /bit OR complement of direct bit to carry 2 2MOV C, bit Move direct bit to carry 2 2 MOV bit, C Move carry to directbit 2 2 JC rel Jump if carry is set 2 2/3 JNC rel Jump if carry not set2 2/3 JB bit rel Jump if direct bit is set 2 3/4 JNB bit, rel Jump ifdirect bit is not set 2 3/4 JBC bit, rel Jump if direct bit is set andclear bit 3 3/4 PROGRAM BRANCHING ACALL addr11 Absolute subroutine call2 3 LCALL addr16 Long subroutine call 3 4 RET Return from subroutine 1 5RETI Return from interrupt 1 5 AJMP addr11 Absolute jump 2 3 LJMP addr16Long jump 3 4 SJMP rel Short jump (relative address) 2 3 JMP @A + DPTRJump indircct relative to DPTR 1 3 JZ rel Jump if A equals zero 2 2/3JNZ rel Jump if A does not equal zero 2 2/3 CJNE A, direct, rel Comparedirect byte to A and jump 3 3/4 if not equal CJNE A, #data, rel Compareimmediate to A and jump 3 3/4 if not equal CJNE Rn, #data, rel Compareimmediate to register and 3 3/4 jump if not equal CJNE @Ri, #data, relCompare immediate to indirect 3 4/5 and jump if not equal DJNZ Rn, relDecrement register and jump if not zero 2 2/3 DJNZ direct, rel Decrementdirect byte and jump if not zero 3 3/4 NOP No operation 1 1Notes on Registers, Operands and Addressing Modes:Rn-Register R0-R7 of the currently selected register bank@Ri-Data RAM location addressed indirectly through register R0-R1rel-8-bit, signed (two's compliment) offset relative to the first byteof the following instruction. Used by SJMP and all conditional jumps.Direct-8-bit internal data location's address. This could be adirect-access Data RAM location (0x00-0x7F) or an SFR (0x80-0xFF).#data-8-bit constant#data 16-16-bit constantbit-Direct-addressed bit in Data RAM or SFR.Addr 11-11-bit destination address used by ACALL and AJMP. Thedestination must be within the same 2K-byte page of program memory asthe first byte of the following instruction.Addr 16-16-bit destination address used by LCALL and LJMP. Thedestination may be anywhere within the 64K-byte program memory space.There is one unused opcode (OxA5) that performs the same function asNOP.All mnemonics copyrighted  © Intel Corporation 1980.Memory Organization

Referring now to FIG. 20, there is illustrated a block diagram of theMemory Map for the memory. The memory organization of theMicrocontroller 40 System Controller is similar to that of a standard8051. There are two separate memory spaces: program memory 690 and datamemory 692. Program and data memory share the same address space but areaccessed via different instruction types. There are 256 bytes ofinternal data memory and 64 K bytes of internal program memory addressspace implemented within the Microcontroller 40.

Program Memory

The Microcontroller 40 has a 64K-byte program memory space. The MCUimplements 32896 bytes of this program memory space as in-system,reprogrammable Flash memory, organized in a contiguous block fromaddresses 0x0000 to 0x807F. Note: 512 bytes (0x7E00-0x7FFF) of thismemory are reserved for factory use and are not available for userprogram storage.

Program memory is normally assumed to be read-only. However, theMicrocontroller 40 can write to program memory by setting the ProgramStore Write Enable bit (PSCTL.7) and using the MOVX instruction. Thisfeature provides a mechanism for the Microcontroller 40 to updateprogram code and use the program memory space for non-volatile datastorage.

Data Memory

The Microcontroller 40 implements 256 bytes of internal RAM mapped intothe data memory space from 0x00 through 0xFF. The lower 128 bytes ofdata memory are used for general purpose registers and scratch padmemory. Either direct or indirect addressing may be used to access thelower 128 bytes of data memory. Locations 0x00 through 0x1F areaddressable as four banks of general purpose registers 694, each bankconsisting of eight byte-wide registers. The next 16 bytes, locations0x20 through 0x2F, may either be addressed as bytes or as 128 bitlocations accessible with the direct addressing mode.

The upper 128 bytes of data memory are accessible only by indirectaddressing. This region occupies the same address space as the SpecialFunction Registers (SFR) but is physically separate from the SFR space.The addressing mode used by an instruction when accessing locationsabove 0x7F determines whether the CPU accesses the upper 128 bytes ofdata memory space or the SFRs. Instructions that use direct addressingwill access the SFR space. Instructions using indirect addressing above0x7F access the upper 128 bytes of data memory.

General Purpose Registers

The lower 32 bytes of data memory, locations 0x00 through 0x1F, may beaddressed as four banks of general-purpose registers. Each bank consistsof eight byte-wide registers designated R0 through R7. Only one of thesebanks may be enabled at a time. Two bits in the program status word, RS0(PSW.3) and RS1 (PSW.4), select the active register bank (seedescription of the PSW in Table 15). This allows fast context switchingwhen entering subroutines and interrupt service routines. Indirectaddressing modes use registers R0 and R1 as index registers.

Bit Addressable Locations

In addition to direct access to data memory organized as bytes, thesixteen data memory locations at 0x20 through 0x2F are also accessibleas 128 individually addressable bits. Each bit has a bit address from0x00 to 0x7F. Bit 0 of the byte at 0x20 has bit address 0x00 while bit 7of the byte at 0x20 has bit address 0x07. Bit 7 of the byte at 0x2F hasbit address 0x7F. A bit access is distinguished from a full byte accessby the type of instruction used (bit source or destination operands asopposed to a byte source or destination).

The MCS-51™ assembly language allows an alternate notation for bitaddressing of the form XX.B where XX is the byte address and B is thebit position within the byte. For example, the instruction:

MOV C, 22.3h

moves the Boolean value at 0x13 (bit 3 of the byte at location 0x22)into the user Carry flag.

Stack

A programmer's stack can be located anywhere in the 256-byte datamemory. The stack area is designated using the Stack Pointer (SP, 0x81)SFR. The SP will point to the last location used. The next value pushedon the stack is placed at SP+1 and then SP is incremented. A resetinitializes the stack pointer to location 0x07. Therefore, the firstvalue pushed on the stack is placed at location 0x08, which is also thefirst register (R0) of register bank 1. Thus, if more than one registerbank is to be used, the SP should be initialized to a location in thedata memory not being used for data storage. The stack depth can extendup to 256 bytes.

The MCU also has built-in hardware for a stack record. The stack recordis a 32-bit shift register, where each Push or increment SP pushes onerecord bit onto the register, and each Call pushes two record bits ontothe register. (A Pop or decrement SP pops one record bit, and a Returnpops two record bits, also.) The stack record circuitry can also detectan overflow or underflow on the 32-bit shift register, and can notifythe emulator software even with the MCU running full-speed emulation.

Special Function Registers

The direct-access data memory locations from 0x80 to 0xFF constitute thespecial function registers (SFRs). The SFRs provide control and dataexchange with the Microcontroller 40's resources and peripherals. TheMicrocontroller 40 duplicates the SFRs found in a typical 8051implementation as well as implementing additional SFRs used to configureand access the sub-systems unique to the MCU. This allows the additionof new functionality while retaining compatibility with the MCS-51™instruction set. Table 16 lists the SFRs implemented in theMicrocontroller 40 System Controller. Registers unique to theMicrocontroller 40 are shown in bold type.

The SFR registers are accessed anytime the direct addressing mode isused to access memory locations from 0x80 to 0xFF. SFRs with addressesending in 0x0 or 0x8 (e.g. P0, TCON, P1, SCON, IE, etc.) arebit-addressable as well as byte-addressable. All other SFRs arebyte-addressable only. Unoccupied addresses in the SFR space arereserved for future use. Accessing these areas will have anindeterminate effect and should be avoided. Table 17 describes theoperation of each register. TABLE 16 Special Function Register MemoryMap

Bit Addressable

TABLE 17 Special Function Registers SFRs listed in alphabetical order.Address Register Description 0xE0 ACC Accumulator 0xBC ADC0CF ADCConfiguration 0xE8 ADC0CN ADC Control 0xC5 ADC0GTH ADC Greater-Than DataWord (High Byte) 0xC4 ADC0GTL ADC Greater-Than Data Word (Low Byte) 0xBFADC0H ADC Data Word (High Byte) 0xBE ADC0L ADC Data Word (Low Byte) 0xC7ADC0LTH ADC Less-Than Data Word (High Byte) 0xC6 ADC0LTL ADC Less-ThanData Word (Low Byte) 0xBA AMX0CF ADC MUX Configuration 0xBB AMX0SL ADCMUX Channel Selection 0xF0 B B Register 0x8E CKCON Clock Control 0x9ECPT0CN Comparator 0 Control 0x9F CPT1CN Comparator 1 Control 0xD4 DAC0CNDAC 0 Control 0xD3 DAC0H DAC 0 Data Word (High Byte) 0xD2 DAC0L DAC 0Data Word (Low Byte) 0xD7 DAC1CN DAC 1 Control 0xD6 DAC1H DAC 1 DataWord (High Byte) 0xD5 DACIL DAC 1 Data Word (Low Byte) 0x83 DPH DataPointer (High Byte) 0x82 DPL Data Pointer (Low Byte) 0x97 DSRFLG DSRFlags ***Not Documented 0xB4 DSRH DSR Data Word (High Byte) 0xB3 DSRLDSR Data Word (Low Byte) ***Not Documented 0xCE DSROP DSR Options 0xE6EIE1 Extended Interrupt Enable 1 0xE7 EIE2 Extended lnterrupt Enable 20xF6 EIP1 External Interrupt Priority 1 0xF7 EIP2 External InterruptPriority 2 0xB7 FLACL Flash Memory Read Limit 0xB6 FLSCL Flash MemoryTiming Prescaler 0xA8 IE Interrupt Enable 0xB8 IP Interrupt PriorityControl 0xB2 OSCICN Internal Oscillator Control 0xB1 OSCXCN ExternalOscillator Control 0x80 P0 Port 0 Latch 0x90 P1 Port 1 Latch 0xA0 P2Port 2 Latch 0xB0 P3 Port 3 Latch 0xD8 PCA0CN Progammable Counter Array0 Control 0xFA PCA0CPH0 PCA Capture Module 0 Data Word (High Byte) 0xFBPCA0CPH1 PCA Capture Module 1 Data Word (High Byte) 0xFC PCA0CPH2 PCACapture Module 2 Data Word (High Byte) 0xFD PCA0CPH3 PCA Capture Module3 Data Word (High Byte) 0xFE PCA0CPH4 PCA Capture Module 4 Data Word(High Byte) 0xEA PCA0CPL0 PCA Capture Module 0 Data Word (Low Byte) 0xEBPCA0CPL1 PCA Capture Module 1 Data Word (Low Byte) 0xEC PCA0CPL2 PCACapture Module 2 Data Word (Low Byte) 0xED PCA0CPL3 PCA Capture Module 3Data Word (Low Byte) 0xEE PCA0CPL4 PCA Capture Module 4 Data Word (LowByte) 0xDA PCA0CPM0 Programmable Counter Array 0 Capture/ Compare 0 0xDBPCA0CPM1 Programmable Counter Array 0 Capture/ Compare 1 0xDC PCA0CPM2Programmable Counter Array 0 Capture/ Compare 2 0xDD PCA0CPM3Programmable Counter Array 0 Capture/ Compare 3 0xDE PCA0CPM4Programmable Counter Array 0 Capture/ Compare 4 0xF9 PCA0H PCACounter/Timer Data Word (High Byte) 0xE9 PCA0L PCA Counter/Timer DataWord (Low Byte) 0xD9 PCA0MD Programmable Counter Array 0 Mode 0x87 PCONPower Control 0xA4 PRT0CF Port 0 Configuration 0xA5 PRT1CF Port 1Configuraton 0xAD PRT1IIF Port 1 Interrupt Flags 0xA6 PRT2CF Port 2Configuration 0xA7 PRT3CF Port 3 Configuration 0x8F PSCTL Program StoreRW Control 0xD0 PSW Program Status Word 0xCB RCAP2H Counter/Timer 2Capture (High Byte) 0xCA RCAP2L Counter/Timer 2 Capture (Low Byte) 0xD1REF0CN Voltage Reference Control Register 0x99 SBUF Serial Data BafferUART 0x98 SCON Serial Port Control UART 0xC3 SMB0ADR SMBus 0 Address0xC0 SMB0CN SMBus 0 Control 0xCF SMB0CR SMBus 0 Clock Rate 0xC2 SMB0DATSMBus 0 Data 0xC1 SMB0STA SMBus 0 Stratus 0x81 SP Stack Pointer 0x9ASPI0CFG Serial Peripheral Interface Configuration 0x9D SPI0CKR SPI ClockRate 0xF8 SPI0CN SPI Bus Control 0x9B SPI0DAT SPI Port 1Data 0xC8 T2CONCounter/Timer 2 Control 0x88 TCON Counter/Timer Control 0x8C TH0Counter/Timer 0 Data Word (High Byte) 0x8D TH1 Counter/Timer 1 Data Word(High Byte) 0xCD TH2 Counter/Timer 2 Data Word (High Byte) 0x8A TL0Counter/Timer 0 Data Word (Low Byte) 0x8B TL1 Counter Timer 1 Data Word(Low Byte) 0xCC TL2 Counter/Timer 2 Data Word (Low Byte) 0x89 TMODCounter/Timer Mode 0x91 TMR3CN Timer 3 Control 0x95 TMR3H Timer 3 High0x94 TMR3L Timer 3 Low 0x93 TMR3RLH Timer 3 Reload High 0x92 TMR3RLLTimer 3 Reload Low 0xFF WDTCN Watchdog Timer Control 0xE1 XBR0 Port I/OCrossbar Configuration 1 0xE2 XBR1 Port I/O Crossbar Configuration 20xE3 XBR2 Port I/O Crossbar Configuration 3 0x84-86, 0x96, 0x9C,Reserved 0xA1-A3, 0xA9-AC, 0xAE-AF, 0xB5, 0xB9, 0xBD, 0xC9 0xDF,0xE4-E5, 0xEF, 0xF1-F5Register Descriptions

In Tables 16-20 are descriptions of SFRs related to the operation of theMicrocontroller 40 System Controller. Reserved bits should not be set tologic 1. The system may use these bits to implement additional featuresin which case the reset value of the bit will be logic 0, selecting thefeature's default state. Detailed descriptions of the remaining SFRs areincluded hereinbelow.

Interrupt Handler

The Microcontroller 40 includes an extended interrupt system supportinga total of 22 interrupt sources with two priority levels. The allocationof interrupt sources between on-chip peripherals and external inputspins varies according to the specific version of the device. Eachinterrupt source has one or more associated interrupt-pending flag(s)located in an SFR. When a peripheral or external source meets a validinterrupt condition, the associated interrupt-pending flag is set tologic 1.

If interrupts are enabled for the source, an interrupt request isgenerated when the interrupt-pending flag is set. As soon as executionof the current instruction is complete, the CPU generates an LCALL to apredetermined address to begin execution of an interrupt service routine(ISR). Each ISR must end with an RETI instruction, which returns programexecution to the next instruction that would have been executed if theinterrupt request had not occurred. If interrupts are not enabled, theinterrupt-pending flag is ignored by the hardware and program executioncontinues as normal. (The interrupt-pending flag is set to logic 1regardless of the interrupt's enable/disable state.)

Each interrupt source can be individually enabled or disabled throughthe use of an associated interrupt enable bit in an SFR (IE-EIE2).However, interrupts must first be globally enabled by setting the EA bit(IE.7) to logic 1 before the individual interrupt enables arerecognized. Setting the EA bit to logic 0 disables all interrupt sourcesregardless of the individual interrupt-enable settings.

Some interrupt-pending flags are automatically cleared by the hardwarewhen the CPU vectors to the ISR. However, most are not cleared by thehardware and must be cleared by software before returning from the ISR.If an interrupt-pending flag remains set after the CPU completes thereturn-from-interrupt (RETI) instruction, a new interrupt request willbe generated immediately and the CPU will re-enter the ISR after thecompletion of the next instruction.

MCU Interrupt Sources and Vectors

The MCU allocates 12 interrupt sources to on-chip peripherals. Up to 10additional external interrupt sources are available depending on the I/Opin configuration of the device. Software can simulate an interrupt bysetting any interrupt-pending flag to logic 1. If interrupts are enabledfor the flag, an interrupt request will be generated and the CPU willvector to the ISR address associated with the interrupt-pending flag.The MCU interrupt sources, associated vector addresses, priority orderand control bits are summarized in _Ref474829042˜. Refer to thedatasheet section associated with a particular on-chip peripheral forinformation regarding valid interrupt conditions for the peripheral andthe behavior of its interrupt-pending flag(s).

External Interrupts

Two of the external interrupt sources (/INT0 and /INT1) are configurableas active-low level-sensitive or active-low edge-sensitive inputsdepending on the setting of IT0 (TCON.0) and IT1 (TCON.2). IE0 (TCON.1)and IE1 (TCON.3) serve as the interrupt-pending flag for the /INT0 and/INT1 external interrupts, respectively. If an /INT0 or /INT1 externalinterrupt is configured as edge-sensitive, the correspondinginterrupt-pending flag is automatically cleared by the hardware when theCPU vectors to the ISR. When configured as level sensitive, theinterrupt-pending flag follows the state of the external interrupt'sinput pin. The external interrupt source must hold the input activeuntil the interrupt request is recognized. It must then deactivate theinterrupt request before execution of the ISR completes or anotherinterrupt request will be generated.

The remaining four external interrupts (External Interrupts 4-7) areactive-low, edge-sensitive inputs. The interrupt-pending flags for theseinterrupts are in the Port 1 Interrupt Flag Register shown in Table 21.TABLE 21 Interrupt Summary Interrupt Priority Interrupt-PendingInterrupt Source Vector Order Flag Enable Reset 0x0000 Top None Alwaysenabled External Interrupt 0x0003 0 IE0 (TCON.1) EX0 (IE.0) (/INT0 Timer0 Overflow 0x000B 1 TF0 (TCON.5) ET0 (IE.1) External Interrupt 1 0x00132 IE1 (TCON.3) EX1 (IE.2) (/INT1 Timer 1 Overflow 0x001B 3 TF1 (TCON.7)ET1 (IE.3) Serial Port (UART) 0x0023 4 RI (SCON.0) ES (IE.4) TI (SCON.1)Timer 2 Overflow (or 0x002B 5 TF2 (T2C0N.7) ET2 (IE.5) EXF2) SerialPeripheral 0x0033 6 SPIF (SPI0STA.7) ESPI0 (EIE1.0) Interface SMBusInterface 0x003B 7 SI (SMB0CN.3) ESMB0 (EIE1.1) ADC0 Window 0x0043 8ADWINT EWADC0 (EIE1.2) Comparison ADC0CN.2 Programmable Counter 0x004B 9CF (PCA0CN.7) EPCA0 (EIE1.3) Array 0 CCFn (PCA0CN.n) Comparator 0Falling 0x0053 10 CP0FIF (CPT0CN.4) ECP0F (EIE1.4) Edge Comparator 0Rising 0x005B 11 CP0RIF ECP0R (EIE1.5) Edge (CPT0CN.3) Comparator 1Falling 0x0063 12 CP1FIF (CPTICN.4) ECP1F (EIE1.6) Edge Comparator 1Rising 0x006B 13 CP1RIF ECP1R (EIE1.7) Edge (CPT1CN.3) Timer 3 (Overflow0x0073 14 TF3 (TMRCN.7) ET3 (EIE2.0) ADC0 End of 0x007B 15 ADCINT EADC0(EIE2.1) Conversion (ADC0CN.5) External Interrupt 4 0x0083 16 IE4(PRT1IF.4 EX4 (EIE2.2) External Interrupt 5 0x008B 17 IE5 (PRT1IF.5) EX5(EIE2.3) External Interrupt 6 0x0093 18 1E6 (PRT1IF.6) EX6 (EIE2.4)External Interrupt 7 0x009B 19 1E7 (PRT1IF.7) EX7 (EIE2.5) JTAGInterface 0x00A3 20 JI (JTAG.X) EJ (EIE2.6) External Crystal OSC 0x00AB21 XVLD (OSCXCN.7) EXVLD (EIE2.7) ReadyInterrupt Priorities

Each interrupt source can be individually programmed to one of twopriority levels: low or high. A low priority interrupt service routinecan be preempted by a high priority interrupt. A high priority interruptcannot be preempted. Each interrupt has an associated interrupt prioritybit in an SFR (IP-EIP2) used to configure its priority level. Lowpriority is the default. If two interrupts are recognizedsimultaneously, the interrupt with the higher priority is servicedfirst. If both interrupts have the same priority level, a fixed priorityorder is used to arbitrate.

Interrupt Latency

Interrupt response time depends on the state of the CPU when theinterrupt occurs. Pending interrupts are sampled and priority decodedeach system clock cycle. Therefore, the fastest possible response timeis 5 system clock cycles: 1 clock cycle to detect the interrupt and 4clock cycles to complete the LCALL to the ISR. If an interrupt ispending when a RETI is executed, a single instruction is executed beforean LCALL is made to service the pending interrupt. Therefore, themaximum response time for an interrupt (when no other interrupt iscurrently being serviced or the new interrupt is of greater priority)occurs when the CPU is performing an RETI instruction followed by a DIVas the next instruction. In this case, the response time is 18 systemclock cycles: 1 clock cycle to detect the interrupt, 5 clock cycles toexecute the RETI, 8 clock cycles to complete the DIV instruction and 4clock cycles to execute the LCALL to the ISR. If the CPU is executing anISR for an interrupt with equal or higher priority, the new interruptwill not be serviced until the current ISR completes, including the RETIand following instruction.

Interrupt Register Descriptions

The SFRs used to enable the interrupt sources and set their prioritylevel are described herein in Tables 22-27 below.

Power Management Modes

The Microcontroller 40 core has two software programmable powermanagement modes: Idle and Stop. Idle mode halts the CPU while leavingthe external peripherals and internal clocks active. In Stop mode, theCPU is halted, all interrupts and timers (except the Missing ClockDetector) are inactive, and the system clock is stopped. Since clocksare running in Idle mode, power consumption is dependent upon the systemclock frequency and the number of peripherals left in active mode beforeentering Idle. Stop mode consumes the least power. Table 28 describesthe Power Control Register (PCON) used to control the Microcontroller40's power management modes.

Although the Microcontroller 40 has Idle and Stop modes built in (aswith any standard 8051 architecture), power management of the entire MCUis better accomplished by enabling/disabling individual peripherals asneeded. Each analog peripheral can be disabled when not in use and putinto low power mode. Digital peripherals, such as timers or serialbuses, draw little power whenever they are not in use. Turning off theFlash memory saves power, similar to entering Idle mode. Turning off theoscillator saves even more power, but requires a reset to restart theMCU.

Idle Mode

Setting the Idle Mode Select bit (PCON.0) causes the Microcontroller 40to halt the CPU and enter Idle mode as soon as the instruction that setsthe bit completes. All internal registers and memory maintain theiroriginal data. All analog and digital peripherals can remain activeduring Idle mode.

Idle mode is terminated when an enabled interrupt or /RST is asserted.The assertion of an enabled interrupt will cause the Idle Mode Selectionbit (PCON.0) to be cleared and the CPU will resume operation. Thepending interrupt will be serviced and the next instruction to beexecuted after the return from interrupt (RETI) will be the instructionimmediately following the one that set the Idle Mode Select bit. If Idlemode is terminated by an internal or external reset, the Microcontroller40 performs a normal reset sequence and begins program execution ataddress 0x0000.

If enabled, the WDT will eventually cause an internal watchdog reset andthereby terminate the Idle mode. This feature protects the system froman unintended permanent shutdown in the event of an inadvertent write tothe PCON register. If this behavior is not desired, the WDT may bedisabled by software prior to entering the Idle mode if the WDT wasinitially configured to allow this operation. This provides theopportunity for additional power savings, allowing the system to remainin the Idle mode indefinitely, waiting for an external stimulus to wakeup the system.

Stop Mode

Setting the Stop Mode Select bit (PCON.1) (Table 28) causes theMicrocontroller 40 to enter Stop mode as soon as the instruction thatsets the bit completes. In Stop mode, the CPU and oscillators arestopped, effectively shutting down all digital peripherals. Each analogperipheral must be shut down individually prior to entering Stop Mode.Stop mode can only be terminated by an internal or external reset. Onreset, the Microcontroller 40 performs the normal reset sequence andbegins program execution at address 0x0000.

If enabled, the Missing Clock Detector will cause an internal reset andthereby terminate the Stop mode. The Missing Clock Detector should bedisabled if the CPU is to be put to sleep for longer than the MCDtimeout of 100 usec.

Flash Memory

Referring now to FIG. 21, there is illustrated a block diagram of theFlash memory. This MCU includes 32k+128 bytes of on-chip, reprogrammableFlash memory for program code and non-volatile data storage. The Flashmemory can be programmed in-system, a single byte at a time, through theJTAG interface or by software using the MOVX instruction. Once clearedto 0, a Flash bit must be erased to set it back to 1. The bytes wouldtypically be erased (set to 0xFF) before being reprogrammed. The writeand erase operations are automatically timed by hardware for properexecution. Data polling to determine the end of the write/eraseoperation is not required. The Flash memory is designed to withstand atleast 10,000 write/erase cycles.

Programming the Flash Memory

The simplest technique of programming the Flash memory is through theJTAG interface using programming tools provided by manufacturer or athird party vendor. This is the only means for programming anon-initialized device. For details on the JTAG commands to programFlash memory.

The Flash memory can be programmed by software using the MOVXinstruction with the address and data byte to be programmed provided asnormal operands. Before writing to Flash memory using MOVX, writeoperations must be enabled by setting the PSWE Program Store WriteEnable bit (PSCTL.0) to logic 1. Writing to Flash remains enabled untilthe PSWE bit is cleared by software.

Writes to Flash memory can clear bits but cannot set them. Only an eraseoperation can set bits in Flash. Therefore, the byte location to beprogrammed must be erased before a new value can be written. The 32kbyte Flash memory is organized in 512-byte sectors. The erase operationapplies to an entire sector (setting all bytes in the sector to 0xFF).Setting the PSEE Program Store Erase Enable bit (PSCTL.1) to logic 1 andthen using the MOVX command to write a data byte to any byte locationwithin the sector will erase an entire 512-byte sector. The data bytewritten can be of any value because it is not actually written to theFlash. Flash erasure remains enabled until the PSEE bit is cleared bysoftware. The following sequence illustrates the algorithm forprogramming the Flash memory by software:

1. Enable Flash Memory write/erase in FLSCL Register using FLASCL bits.

2. Set PSEE (PSCTL.1) to enable Flash sector erase.

3. Set PSWE (PSCTL.0) to enable Flash writes.

4. Use MOVX to write a data byte to any location within the 512-bytesector to be erased.

5. Clear PSEE to disable Flash sector erase.

6. Use MOVX to write a data byte to the desired byte location within theerased 512-byte sector. Repeat until finished. (Any number of bytes canbe written from a single byte to and entire sector.)

7. Clear the PSWE bit to disable Flash writes.

Write/Erase timing is automatically controlled by hardware based on theprescaler value held in the Flash Memory Timing Prescaler register(FLSCL). The 4-bit prescaler value FLASCL determines the time intervalfor write/erase operations. The FLASCL value required for a given systemclock is shown in Table 30, along with the formula used to derive theFLASCL values. When FLASCL is set to 1111b, the write/erase operationsare disabled. Note that code execution in the 8051 is stalled while theFlash is being programmed or erased.

Non-Volatile Data Storage

The Flash memory can be used for non-volatile data storage as well asprogram code. This allows data such as calibration coefficients to becalculated and stored at run time. Data is written using the MOVXinstruction and read using the MOVC instruction.

The MCU incorporates an additional 128-byte sector of Flash memorylocated at 0x8000-0x807F. This sector can be used for program code ordata storage. However, its smaller sector size makes it particularlywell suited as general purpose, non-volatile scratchpad memory. Eventhough Flash memory can be written a single byte at a time, an entiresector must be erased first. In order to change a single byte of amulti-byte data set, the data must be moved to temporary storage. Next,the sector is erased, the data set updated and the data set returned tothe original sector. The 128-byte sector-size facilitates updating datawithout wasting program memory space by allowing the use of internaldata RAM for temporary storage. (A normal 512-byte sector is too largeto be stored in the 256-byte internal data memory.)

Security Options

The Microcontroller 40 provides security options to protect the Flashmemory from inadvertent modification by software as well as prevent theviewing of proprietary program code and constants. The Program StoreWrite Enable (PSCTL.0) (Table 29) and the Program Store Erase Enable(PSCTL.1) bits protect the Flash memory from accidental modification bysoftware. These bits must be explicitly set to logic 1 before softwarecan modify the Flash memory. Additional security features preventproprietary program code and data constants from being read or alteredacross the JTAG interface or by software running on the systemcontroller. Tables 30 and 31 illustrate these features.

A set of security lock bytes stored at 0x7DFE and 0x7DFF protect theFlash program memory from being read or altered across the JTAGinterface. Each bit in a security lock-byte protects one 4 kbyte blockof memory. Clearing a bit to logic 0 in a Read lock byte prevents thecorresponding block of Flash memory from being read across the JTAGinterface. Clearing a bit in the Write/Erase lock byte protects theblock from JTAG erasures and/or writes. The Read lock byte is atlocation 0x7DFF. The Write/Erase lock byte is located at 0x7DFE. FIG. 21shows the location and bit definitions of the security bytes. The sectorcontaining the lock byte cannot be erased by software.

The lock bits can always be read and cleared to logic 0 regardless ofthe security setting applied to the block containing the security bytes.This allows additional blocks to be protected after the block containingthe security bytes has been locked. However, the only means of removinga lock once set is to erase the entire program memory space byperforming a JTAG erase operation. It is noted that erasing the Flashmemory block containing the security bytes will automatically initiateerasure of the entire program memory space (except for the reservedarea). This erasure can only be performed via the JTAG.

The Flash Access Limit security feature protects proprietary programcode and data from being read by software running on the Microcontroller40. This feature provides support for OEMs that wish to program the MCUwith proprietary value-added firmware before distribution. Thevalue-added firmware can be protected while allowing additional code tobe programmed in remaining program memory space later.

The Software Read Limit (SRL) is a 16-bit address that establishes twological partitions in the program memory space. The first is an upperpartition consisting of all the program memory locations at or above theSRL address, and the second is a lower partition consisting of all theprogram memory locations starting at 0x0000 up to (but excluding) theSRL address. Software in the upper partition can execute code in thelower partition, but is prohibited from reading locations in the lowerpartition using the MOVC instruction. (Executing a MOVC instruction fromthe upper partition with a source address in the lower partition willalways return a data value of 0x00.) Software running in the lowerpartition can access locations in both the upper and lower partitionwithout restrictions.

The Value-added firmware should be placed in the lower partition. Onreset, control is passed to the value-added firmware via the resetvector. Once the value-added firmware completes its initial execution,it branches to a predetermined location in the upper partition. If entrypoints are published, software running in the upper partition mayexecute program code in the lower partition, but it cannot read thecontents of the lower partition. Parameters may be passed to the programcode running in the lower partition either through the typical method ofplacing them on the stack or in registers before the call or by placingthem in prescribed memory locations in the upper partition.

The SRL address is specified using the contents of the Flash AccessRegister. The 16-bit SRL address is calculated as 0xNN00, where NN isthe contents of the SRL Security Register. Thus, the SRL can be locatedon 256-byte boundaries anywhere in program memory space. However, the512-byte erase sector size essentially requires that a 512 boundary beused. The contents of a non-initialized SRL security byte is 0x00,thereby setting the SRL address to 0x0000 and allowing read access toall locations in program memory space by default.

Reset Sources

Referring back to FIG. 3, the reset circuitry of the MCU allows thecontroller to be easily placed in a predefined default condition. Onentry to this reset state, the Microcontroller 40 halts programexecution, forces the external port pins to a known state andinitializes the SFRs to their defined reset values. Interrupts andtimers are disabled. On exit, the program counter (PC) is reset, andprogram execution starts at location 0x0000.

All of the SFRs are reset to predefined values. The reset values of theSFR bits are defined in the SFR detailed descriptions. The contents ofinternal data memory are not changed during a reset and any previouslystored data is preserved. However, since the stack pointer SFR is reset,the stack is effectively lost even though the data on the stack are notaltered.

The I/O port latches are reset to 0xFF (all logic ones), activatinginternal weak pull-ups which take the external I/O pins to a high state.The external I/O pins do not go high immediately, but will go highwithin 4 system clock cycles after entering the reset state. If thesource of reset is from the VDD Monitor, the /RST pin is driven lowuntil the end of the VDD reset timeout.

On exit from the reset state, the Core 40 uses the internal oscillatorrunning at 1.9 MHz as the system clock by default. The Watchdog Timer102 is enabled using its longest timeout interval. Once the system clocksource is stable, program execution begins at location 0x0000.

There are seven sources for putting the MCU into the reset state:power-on/power-fail, external /RST pin, external CNVSTR signal, softwarecommanded, Comparator 0, Missing Clock Detector, and Watchdog Timer.Each reset source is described below:

Power-On Reset

The Microcontroller 40 incorporates a power supply monitor that holdsthe MCU in the reset state until VDD rises above the V_(RST) levelduring power-up. The /RST pin is asserted (low) until the end of the 100msec VDD Monitor timeout in order to allow the VDD supply to becomestable.

On exit from a power-on reset, the PORSF flag (RSTSRC.1) is set byhardware to logic 1. All of the other reset flags in the RSTSRC Registerare indeterminate. It is cleared by all other resets. Since all resetscause program execution to begin at the same location (0x0000) softwarecan read the PORSF flag to determine if a power-up was the cause ofreset. The content of internal data memory should be assumed to beundefined after a power-on reset.

Software Forced Reset

Writing a 1 to the PORSF bit forces a Power-On Reset.

Power-Fail Reset

When a power-down transition or power irregularity causes V_(DD) to dropbelow V_(RST), the power supply monitor will drive the /RST pin low andreturn the Microcontroller 40 to the reset state (see FIG. 22). WhenV_(DD) returns to a level above V_(RST), the Microcontroller 40 willleave the reset state in the same manner as that for the power-on reset.Note that even though internal data memory contents are not altered bythe power-fail reset, it is impossible to determine if VDD dropped belowthe level required for data retention. If the PORSF flag is set, thedata may no longer be valid.

External Reset

The external /RST pin provides a means for external circuitry to forcethe Microcontroller 40 into a reset state. Asserting an active-lowsignal on the /RST pin will cause the Microcontroller 40 to enter thereset state. It may be desirable to provide an external pull-up and/ordecoupling of the /RST pin to avoid erroneous noise-induced resets. TheMicrocontroller 40 will remain in reset until at least 12 clock cyclesafter the active-low /RST signal is removed. The PINRSF flag (RSTSRC.0)is set on exit from an external reset.

Missing Clock Detector Reset

The Missing Clock Detector is essentially a one-shot circuit that istriggered by the MCU system clock. If the system clock goes away formore than 100 usec, the one-shot will time out and generate a reset.After a Missing Clock Detector reset, the MCDRSF flag (RSTSRC.2) will beset, signifying the MSD as the reset source; otherwise, this bit reads0. The state of the /RST pin is unaffected by this reset. Setting theMSCLKE bit in the OSCICN register enables the Missing Clock Detector.

Comparator 0 Reset

Comparator 0 can be configured as a reset input by writing a 1 to theC0RSEF flag (RSTSRC.5). Comparator 0 should be enabled using CPT0CN.7(see Table 11) prior to writing to C0RSEF to prevent any turn-on chatteron the output from generating an unwanted reset. When configured as areset, if the non-inverting input voltage (on CP0+) is less than theinverting input voltage (on CP0−), the MCU is put into the reset state.After a Comparator 0 Reset, the C0RSEF flag (RSTSRC.5) will read 1signifying Comparator 0 as the reset source; otherwise, this bit reads0. The state of the /RST pin is unaffected by this reset.

External CNVSTR Pin Reset

The external CNVSTR signal can be configured as a reset input by writinga 1 to the CNVRSEF flag (RSTSRC.6). The CNVSTR signal can appear on anyof the P0, P1, or P2 I/O pins. (Note that the Crossbar 52 must beconfigured for the CNVSTR signal to be routed to the appropriate PortI/O.) The Crossbar 52 should be configured and enabled before theCNVRSEF is set to configure CNVSTR as a reset source. When configured asa reset, CNVSTR is active-low and level sensitive. After a CNVSTR reset,the CNVRSEF flag (RSTSRC.6) will read 1 signifying CNVSTR as the resetsource; otherwise, this bit reads 0. The state of the /RST pin isunaffected by this reset.

Watchdog Timer Reset

The MCU includes a programmable Watchdog Timer (WDT) running off thesystem clock. The WDT will force the MCU into the reset state when thewatchdog timer overflows. To prevent the reset, the WDT must berestarted by application software before overflow. If the systemexperiences a software/hardware malfunction preventing the software fromrestarting the WDT, the WDT will overflow and cause a reset. This shouldprevent the system from running out of control.

The WDT is automatically enabled and started with the default maximumtime interval on exit from all resets. If desired the WDT can bedisabled by system software or locked on to prevent accidentaldisabling. Once locked, the WDT cannot be disabled until the next systemreset. The state of the /RST pin is unaffected by this reset.

Watchdog Usage

The WDT consists of a 21-bit timer running from the programmed systemclock. The timer measures the period between specific writes to itscontrol register. If this period exceeds the programmed limit, a WDTreset is generated. The WDT can be enabled and disabled as needed insoftware, or can be permanently enabled if desired. Watchdog featuresare controlled via the Watchdog Timer Control Register (WDTCN) shown inTable 32.

Enable/Reset WDT

The watchdog timer is both enabled and reset by writing 0xA5 to theWDTCN register. The user's application software should include periodicwrites of 0xA5 to WDTCN as needed to prevent a watchdog timer overflow.The WDT is enabled and reset as a result of any system reset.

Disable WDT

Writing 0xDE followed by 0xAD to the WDTCN register disables the WDT.The following code segment illustrates disabling the WDT. CLR EA ;disable all interrupts MOV WDTCN, #0DEh ; disable software MOV WDTCN,#0ADh ; watchdog timer SETB EA ; re-enable interruptsThe writes of 0xDE and 0xAD must occur within 4 clock cycles of eachother, or the disable operation is ignored. Interrupts should bedisabled during this procedure to avoid delay between the two writes.Disable WDT Lockout

Writing 0xFF to WDTCN locks out the disable feature. Once locked out,the disable operation is ignored until the next system reset. Writing0xFF does not enable or reset the watchdog timer. Applications alwaysintending to use the watchdog should write 0xFF to WDTCN in theirinitialization code.

Setting WDT Interval

WDTCN[2:0] control the watchdog timeout interval. The interval is givenby the following equation:4^(3+WDTCN[2:0]) ×T _(SYSCLK), (where T_(SYSCLK) is the system clockperiod).For a 1.9 MHz system clock, this provides an interval range of 0.0337msec to 552 msec. WDTCN.7 must be a 0 when setting this interval.Reading WDTCN returns the programmed interval. WDTCN[2:0] is 111b aftera system reset.Oscillator

Referring now to FIG. 23, there is illustrated a block diagram of theinternal oscillator 112 and an external oscillator drive circuit 37,either of which can generate the system clock. The MCU boots from theinternal oscillator after any reset. This internal oscillator 112 can beenabled/disabled and its frequency can be set using an InternalOscillator Control Register (OSCICN) as shown in [Table].

Both oscillators are disabled when the /RST pin is held low. The MCU canrun from the internal oscillator 112 permanently, or it can switch tothe external oscillator 37 if desired using CLKSL bit in the OSCICNRegister 750 (Table 36). The external oscillator requires an externalresonator, crystal, capacitor, or RC network connected to theXTAL1/XTAL2 pins (see _Ref476033593˜). The oscillator circuit must beconfigured for one of these sources in the OSCXCN register 752 (Table37). An external CMOS clock can also provide the system clock viaoverdriving the XTAL1 pin.

External Crystal Example

If a crystal were used to generate the system clock for the MCU, thecircuit would be as shown in FIG. 23, Option 1. For an ECS-110.5-20-4crystal, the resonate frequency is 11.0592 MHz, the intrinsiccapacitance is 7 pF, and the ESR is 60W. The compensation capacitorsshould be 33 pF each, and the PWB parasitic capacitance is estimated tobe 2 pF. To find the appropriate External Oscillator Frequency Controlvalue (XFCN) in the OSCXCN Register 752, the Power Factor must becalculated. First, find the equivalent load capacitance as follows:

C_(L)=CO+[(C1*C2)/(C1+C2)]+CP/2

C_(L)=7+(33*33)/(33+33)+2/2

C_(L)=7+16.5+1

C_(L)=24.5 pF

The Power Factor is calculated as follows:

F=5*ESR*f²*C_(L) ²

PF=5*60*(11.0592)²*(24.5)²

PF=22(10⁶)

From the Crystal column in Table 37, the first PF value which is greaterthan 22(10⁶) is 6.6(10⁶), so the XFCN value to use is 110.

External RC Example

If an external RC network were used to generate the system clock for theMCU, the circuit would be as shown in FIG. 23, Option 2. The capacitormust be no greater than 100 pF, but using a very small capacitor willincrease the frequency drift due to the PWB parasitic capacitance. Todetermine the required External Oscillator Frequency Control value(XFCN) in the OSCXCN Register 752, first select the RC network value toproduce the desired frequency of oscillation. If the frequency desiredis 100 kHz, let R=246 kW and C=50 pF:f=1.23(10³)/RC=1.23(10³)/[246*50]=01 MHz=100 kHzXFCN³ log₂(f/25 kHz)XFCN³ log₂(100 kHz/25 kHz)=log₂(4)XFCN³ 2, or code 010External Capacitor Example

If an external capacitor were used to generate the system clock for theMCU, the circuit would be as shown in FIG. 23, Option 3. The capacitormust be no greater than 100 pF, but using a very small capacitor willincrease the frequency drift due to the PWB parasitic capacitance. Todetermine the required External Oscillator Frequency Control value(XFCN) in the OSCXCN Register 752, select the capacitor to be used andfind the frequency of oscillation from the equations below. AssumeAV+=3.0V and C=50 pF:

f=KF/(C*VDD)=KF/(50*3)

f=KF/150

If a frequency of roughly 400 kHz is desired, select the K Factor fromthe table in _Ref472223418˜ as KF=60.8:

f=60.8/150=0.405 MHz, or 405 kHz

Therefore, the XFCN value to use in this example is 011.

RT Input/Output

Description

Referring back to FIG. 6, there is illustrated a diagram of the Port I10functionality. The MCU has a wide array of digital resources, which areavailable through four digital I/O ports, P0, P1, P2 and P3. Each portpin can be defined as its corresponding port I/O or it can have one ofthe internal digital resources. The designer has complete control overwhich functions are assigned, limited only by the number of physical I/Opins available on the selected package. This is achieved through the useof the Priority CrossBar Decoder 404. (Note that the state of a Port I/Opin can always be read in the corresponding Port latch regardless of theCrossbar settings).

The CrossBar 52 assigns the selected internal digital resources to theI/O pins based on the Priority Decode Table 38. The registers XBR0,XBR1, and XBR2, defined in Tables 39, 40 and 41 are used to select aninternal digital function or let an I/O pin default to being a Port I/O.

All Port I/Os are 5V tolerant (FIG. 24 illustrates a Cell BlockDiagram.) The Port I/O cells are configured as either push-pull oropen-drain in the Port Configuration Registers (PRT0CF, PRT1CF, PRT2CF,PRT3CF).

Priority Cross Bar Decoder

The Priority CrossBar Decode 404 assigns a priority to each I/Ofunction, starting at the top with the SMBus. When selected, its twosignals will be assigned to Pin 0 and 1 of I/O Port 0. The decoderalways fills I/O bits from LSB to MSB starting with Port 0, then Port 1,finishing if necessary with Port 2. If the designer chooses not to use aresource, the next function will fill the priority slot. In this way, itis possible to choose only the functions required by the design makingfull use of the available I/O pins. Also, any extra Port I/O are groupedtogether for more convenient use in application code.

Registers XBR0, XBR1 and XBR2 are used to assign the digital I/Oresources to the physical I/O Port pins. When the SMBus, SPI Bus, orUART is selected, the crossbar 52 assigns all pins associated with theselected bus. It would be impossible for instance to assign the RX pinfrom the UART function without also assigning the TX function. StandardPort I/Os appear contiguously after the prioritized functions have beenassigned. For example, if you choose functions that take the first 14Port I/O (P0.[7:0], P1.[5:0]), you would have 18 Port I/O left over(P1.[7:6], P2 and P3). The crossbar circuit is described in U.S. patentapplication Ser. No. 09/583,260, filed May 31, 2000, entitled “Cross-BarMatrix for Connecting Digital Resources to 110 Pairs of an IntegratedCircuit,” (Atty. Dkt. CYGL-25,155), which is incorporated herein byreference.

Port I/O Initialization

Port I/O initialization is straightforward. Registers XBR0, XBR1 andXBR2 must be loaded with the appropriate values to select the digitalI/O functions required by the design. Setting XBR2.7 to 1 enables theCrossBar 52. Until the Crossbar 52 is enabled, the external pins remainas standard Ports in input mode regardless of the XBRn Registersettings. For given XBRn Register settings, one can determine the I/Opin-out using the Priority Decode Table; as an alternative, theConfiguration Code Generator function of the IDE software will determinethe Port I/O pin-assignments based on the XBRn Register settings.

The output driver characteristics of the I/O pins are defined using thePort Configuration Registers PRT0CF, PRT1CF, PRT2CF and PRT3CF (seeTables 43, 45, 48 and 50). Each Port Output driver can be configured aseither Open Drain or Push-Pull. This is required even for the digitalresources selected in the XBRn registers and is not automatic. The onlyexception to this is the SMBus (SDA, SCL) and UART Receive (RX) pinswhich are Open-drain regardless of the PRTnCF settings.

The third and final step is to initialize the individual resourcesselected using the appropriate setup registers. Initializationprocedures for the various digital resources may be found in thedetailed explanation of each available function. The reset state of eachregister is shown in Tables 42-50 that describe each individualregister. TABLE 38 Crossbar Priority Decode

In the Priority Decode Table 38, a dot (•) is used to show the externalPort I/O pin (column) to which each signal (row) can be assigned by theuser application code via programming registers XBR2, XBR1, and XBR0.General Purpose Port I/O

The MCU has four byte-wide, bi-directional parallel ports that can beused general purpose I/O. Each port is accessed through a correspondingspecial function register (SFR) that is both byte addressable and bitaddressable. When writing to a port, the value written to the SFR islatched to maintain the output data value at each pin. When reading, thelogic levels of the port's input pins are returned regardless of theXBRn settings (i.e. even when the pin is assigned to another signal bythe Crossbar, the Port Register can always still read its correspondingPort I/O pin). The exception to this is the execution of theread-modify-write instructions. The read-modify-write instructions whenoperating on a port SFR are the following: ANL, ORL, XRL, JBC, CPL, INC,DEC, DJNZ and MOV, CLR or SET, when the destination is an individual bitin a port SFR. For these instructions, the value of the register (notthe pin) is read, modified, and written back to the SFR.

Serial I/O

Description

Referring now to FIGS. 25A and 25B, there is illustrated a block diagramof the SMBus. The SMBus serial I/O interface is compliant with theSystem Management Bus Specification, version 1.1. It is a two-wire,bi-directional serial bus, which is also compatible with the I²C serialbus. Reads and writes to the interface by the system controller are byteoriented with the SMBus interface autonomously controlling the serialtransfer of the data. Data can be transferred at up to ⅛^(th) of thesystem clock if desired (this can be faster than allowed by the SMBusspecification, depending on the system clock used). A method ofextending the clock-low duration is used to accommodate devices withdifferent speed capabilities on the same bus.

Two types of data transfers are possible: data transfers from a mastertransmitter to an addressed slave receiver, and data transfers from anaddressed slave transmitter to a master receiver. The master deviceinitiates both types of data transfers and provides the serial clockpulses. The SMBus interface may operate as a master or a slave. Multiplemaster devices on the same bus are also supported. If two or moremasters attempt to initiate a data transfer simultaneously, anarbitration scheme is employed with a single master always winning thearbitration.

FIG. 26 shows a typical SMBus configuration. The SMBus interface willwork at any voltage between 3.0V and 5.0V and different devices on thebus may operate at different voltage levels. The SCL (serial clock) online 780 and SDA (serial data) on line 782 are bi-directional. They mustbe connected to a positive power supply voltage through a pull-upresistor or similar circuit 784. When the bus is free, both lines arepulled high. Every device connected to the bus must have an open-drainor open-collector output for both the SCL and SDA lines. The maximumnumber of devices on the bus is limited only by the requirement that therise and fall times on the bus will not exceed 300 ns and 1000 ns,respectively.

Operation

A typical SMBus transaction consists of a START condition, followed byan address byte, one or more bytes of data, and a STOP condition. Theaddress byte and each of the data bytes are followed by an ACKNOWLEDGEbit from the receiver. The address byte consists of a 7-bit address plusa direction bit. The direction bit (R/W) occupies the least-significantbit position of the address. The direction bit is set to logic 1 toindicate a “READ” operation and cleared to logic 0 to indicate a “WRITE”operation. A general call address (0x00+R/W) is recognized by all slavedevices allowing a master to address multiple slave devicessimultaneously.

All transactions are initiated by the master with one or more addressedslave devices as the target. The master generates the START conditionand then transmits the address and direction bit. If the transaction isa WRITE operation from the master to the slave, the master transmits thedata a byte at a time waiting for an ACKNOWLEDGE from the slave at theend of each byte. If it is a READ operation, the slave transmits thedata waiting for an ACKNOWLEDGE from the master at the end of each byte.At the end of the data transfer, the master generates a STOP conditionto terminate the transaction and free the bus. FIG. 27 illustrates atypical SMBus transaction. The SMBus interface may be configured tooperate as either a master or a slave. At any particular time, it willbe operating in one of the following four modes:

Serial data is transmitted on SDA while the serial clock is output onSCL. The first byte transmitted contains the address of the target slavedevice and the data direction bit. In this case the data direction bit(R/W) will be logic 0 to indicate a “WRITE” operation. The master thentransmits one or more bytes of serial data. After each byte istransmitted, an acknowledge bit is generated by the slave. START andSTOP conditions are output by the master device to indicate thebeginning and the end of the serial transfer.

Serial data is received on SDA while the serial clock is output on SCL.The first byte is transmitted by the master and contains the address ofthe target slave and the data direction bit. In this case the datadirection bit (R/W) will be logic 1 to indicate a “READ” operation.Serial data is then received from the slave on SDA while the masteroutputs the serial clock. One or more bytes of serial data aretransmitted by the slave. After each byte is received, an acknowledgebit is transmitted by the master. START and STOP conditions are outputby the master to indicate the beginning and end of the serial transfer.

Serial data is transmitted on SDA while the serial clock is received onSCL. First, a byte is received that contains an address and datadirection bit. In this case the data direction bit (R/W) will be logic 1to indicate a “READ” operation. If the received address matches theslave's assigned address (or a general call address is received) one ormore bytes of serial data are transmitted to the master. After each byteis received, an acknowledge bit is transmitted by the master. The masteroutputs START and STOP conditions to indicate the beginning and end ofthe serial transfer.

Serial data is received on SDA while the serial clock is received onSCL. First, a byte is received that contains an address and datadirection bit. In this case the data direction bit (R/W) will be logic 0to indicate a “WRITE” operation. If the received address matches theslave's assigned address (or a general call address is received) one ormore bytes of serial data are received from the master. After each byteis received, an acknowledge bit is transmitted by the slave. START andSTOP conditions are output by the master to indicate the beginning andend of the serial transfer.

A master may start a transfer only if the bus is free. The bus is freeafter a STOP condition or after the SCL and SDA lines remains high for aspecified time. Two or more master devices may attempt to generate aSTART condition at the same time. Since the devices that generated theSTART condition may not be aware that other masters are contending forthe bus, an arbitration scheme is employed. The master devices continueto transmit until one of the masters transmits a HIGH level, while theother(s) master transmits a LOW level on SDA. The first master(s)transmitting the HIGH level on SDA looses the arbitration and isrequired to give up the bus.

SMBus provides a clock synchronization mechanism, similar to I2C, whichallows devices with different speed capabilities to coexist on the bus.A clock-low extension is used during a transfer in order to allow slowerslave devices to communicate with faster masters. The slave can hold theSCL line LOW to extend the clock low period, effectively decreasing theserial clock frequency.

If the SCL line is held low by a slave device on the bus, no furthercommunication is possible. Furthermore, the master cannot force the SCLline high to correct the error condition. To solve this problem, theSMBus protocol specifies that devices participating in a transfer mustdetect any clock cycle held low longer than 25 ms as a “timeout”condition. Devices that have detected the timeout condition must resetthe communication no later than 10 ms after detecting the timeoutcondition.

One of the MCU's general-purpose timers, operating in 16-bit auto-reloadmode, can be used to monitor the SCL line for this timeout condition.Timer 3 is specifically designed for this purpose.

The SMBus specification stipulates that if a device holds the SCL andSDA lines high for more that 50 usec, the bus is designated as free. TheSMB0CR register is used to detect this condition when the FTE bit inSMB0CN is set, thereby setting the SI bit in SMB0CN if this event isdetected.

SMBus Special Function Registers

The SMBus serial interface is accessed and controlled through five SFRs:SMB0CN Control Register, SMB0CR Clock Rate Register, SMB0ADR AddressRegister, SMB0DAT Data Register and SMB0STA Status Register. The systemdevice may have one or more SMBus serial interfaces implemented. Thefive special function registers related to the operation of the SMBusinterface are described in the following section.

Control Register

The SMBus Control register SMB0CN (Table 51) is used to configure andcontrol the SMBus interface. All of the bits in the register can be reador written by software. Two of the control bits are also affected by theSMBus hardware. The Serial Interrupt flag (SI, SMB0CN.3) is set to logic1 by the hardware when a valid serial interrupt condition occurs. It canonly be cleared by software. The Stop flag (STO, SMB0CN.4) is cleared tologic 0 by hardware when a STOP condition is present on the bus.

Setting the ENSMS flag to logic 1 enables the SMBus interface. Clearingthe ENSMB flag to logic 0 disables the SMBus interface and removes itfrom the bus. Momentarily clearing the ENSMB flag and then resetting itto logic 1 will reset a SMBus communication. However, ENSMB should notbe used to temporarily remove a device from the bus since the bus stateinformation will be lost. Instead, the Assert Acknowledge (AA) flagshould be used to temporarily remove the device from the bus (seedescription of AA flag below).

Setting the Start flag (STA, SMB0CN.5) to logic 1 will put the SMBus ina master mode. If the bus is free, the SMBus hardware will generate aSTART condition. If the bus is not free, the SMBus hardware waits for aSTOP condition to free the bus and then generates a START conditionafter a 5 us delay per the SMB0CR value. (In accordance with the SMBusprotocol, the SMBus interface also considers the bus free if the bus isidle for 50 us and no STOP condition was recognized.) If STA is set tologic 1 while the SMBus is in master mode and one or more bytes havebeen transferred, a repeated START condition will be generated.

When the Stop flag (STO, SMB0CN.4) is set to logic 1 while the SMBusinterface is in master mode, the hardware generates a STOP condition onthe SMBus. In a slave mode, the STO flag may be used to recover from anerror condition. In this case, a STOP condition is not generated on theSMBus, but the SMBus hardware behaves as if a STOP condition has beenreceived and enters the “not addressed” slave receiver mode. The SMBushardware automatically clears the STO flag to logic 0 when a STOPcondition is detected on the bus.

The Serial Interrupt flag (SI, SMB0CN.3) is set to logic 1 by hardwarewhen the SMBus interface enters one of 27 possible states. If interruptsare enabled for the SMBus interface, an interrupt request is generatedwhen the SI flag is set. The SI flag must be cleared by software. If SIis set to logic 1 while the SCL line is low, the clock-low period of theserial clock will be stretched and the serial transfer is suspended. Ahigh level on SCL is not affected by the setting of the SI flag.

The Assert Acknowledge flag (AA, SMB0CN.2) is used to set the level ofthe SDA line during the acknowledge clock cycle on the SCL line. Settingthe AA flag to logic 1 will cause an ACKNOWLEDGE (low level on SDA) tobe sent during the acknowledge cycle if the device has been addressed.Setting the AA flag to logic 0 will cause a NOT ACKNOWLEDGE (high levelon SDA) to be sent during acknowledge cycle. After the transmission of abyte in slave mode, the slave can be temporarily removed from the bus byclearing the AA flag. The slave's own address and general call addresswill be ignored. To resume operation on the bus, the AA flag must bereset to logic 1 to allow the slave's address to be recognized.

Setting the SMBus Free Timer Enable bit (FTE, SMB0CN.1) to logic 1enables the timer in SMB0CR. When SCL goes high, the timer in SMB0CRcounts up. If it overflows, the bus will be freed from being be drivenby the master. The bus free period should be less than 50 usec (seeTable 52, SMBus Clock Rate Register).

Setting the SMBus timeout enable bit to logic 1 enables Timer 3 to countup when the SCL line is high and Timer 3 is enabled. If Timer 3overflows, a Timer 3 interrupt will be generated, which will alert theCPU that a SMBus SCL low timeout has occurred.

Clock Rate Register

Data Register

The SMBus Data register SMB0DAT (Table 53) holds a byte of serial datato be transmitted or one that has just been received. Software can reador write to this register while the SI flag is set to logic 1. Dataremains stable in the register as long as SI is set to logic 1. Softwarecan safely read or write to the data register when the SI flag is set.Software should not attempt to access the SMB0DAT register when theSMBus is enabled and the SI flag is cleared to logic 0 since thehardware may be in the process of shifting a byte of data in or out ofthe register.

Data in SMB0DAT is always shifted out MSB first. After a byte has beenreceived, the first bit of received data is located at the MSB ofSMB0DAT. While data is being shifted out, data on the bus issimultaneously being shifted in. Therefore, SMB0DAT always contains thelast data byte present on the bus. Thus, in the event of lostarbitration, the transition from master transmitter to slave receiver ismade with the correct data in SMB0DAT.

Address Register

The SMB0ADR Address register (Table 54) holds the slave address for theSMBus interface. In slave mode, the seven most-significant bits hold the7-bit slave address. The least significant bit, bit 0, is used to enablethe recognition of the general call address (0x00). If bit 0 is set tologic 1, the general call address will be recognized. Otherwise, thegeneral call address is ignored. The contents of this register areignored when the SMBus hardware is operating in master mode.

Status Register

The SMB0STA Status register (Table 55) holds an 8-bit status codeindicating the current state of the SMBus. There are 28 possible SMBusstates, each with a corresponding unique status code. The five mostsignificant bits of the status code vary while the threeleast-significant bits of a valid status code are fixed at zero whenSI=1. Therefore, all possible status codes are multiples of eight. Thisfacilitates the use of status codes in software as an index used tobranch to appropriate service routines (allowing 8 bytes of code toservice the state or jump to a more extensive service routine).

For the purposes of user software, the contents of the SMB0STA registeris only defined when the SI flag is logic 1. Software should never writeto the SMB0STA register. Doing so will yield indeterminate results. The28 SMBus states, along with their corresponding status codes, are givenin Table 56. TABLE 56 SMBus Status Codes Status Code SMB0STA Mode SMBusState 0x00 All Bus Error (i.e. illegal START, illegal STOP, . . . 0x08Master START condition transmitted. Transmitter/Receiver 0x10 MasterRepeated START condition transmitted. Transmitter/Receiver 0x18 MasterTransmitter Slave address + W transmitted. ACK received. 0x20 MasterTransmitter Slave address + W transmitted. NACK received. 0x28 MasterTransmitter Data byte transmitted. ACK received. 0x30 Master TransmitterData byte transmitted. NACK received. 0x38 Master TransmitterArbitration lost 0x40 Master Receiver Slave address + R transmitted. ACKreceived. 0x48 Master Receiver Slave address + R transmitted. NACKreceived. 0x50 Master Receiver Data byte received. ACK transmitted. 0x58Master Receiver Data byte received. NACK transmitted. 0x60 SlaveReceiver SMB0's own slave address + W received. ACK transmitted. 0x68Slave Receiver Arbitration lost in transmitting slave address + R/W asmaster. Own slave address + W received. ACK transmitted. 0x70 SlaveReceiver General call address (0x00) received. ACK returned. 0x78 SlaveReceiver Arbitration lost in transmitting slave address + R/W as master.General call address received. ACK transmitted. 0x80 Slave ReceiverSMB0's own slave address + W received. Data byte received. ACKtransmitted. 0x88 Slave Receiver SMB0's own slave address + W received.Data byte received. NACK transmitted. 0x90 Slave Receiver General calladdress (0x00) received. Data byte received. ACK transmitted. 0x98 SlaveReceiver General call address (0x00) received. Data byte received. NACKtransmitted. 0xA0 Slave Receiver A STOP or repeated START received whileaddresses as a slave. 0xA8 Slave Transmitter SMB0's own slave address +R received. ACK transmitted. 0xB0 Slave Transmitter Arbitration lost intransmitting slave address + R/W as master. Own slave address + Rreceived. ACK transmitted. 0xB8 Slave Transmitter Data byte transmitted.ACK received 0xC0 Slave Transmitter Data byte transmitted. NACKreceived. 0xC8 Slave Transmitter Last data byte transmitted (AA = 0).ACK received 0xD0 Slave SCL Clock High Timer per SMB0CR timed outTransmitter/Receiver (FTE = 1) 0xF8 All IdleSerial Peripheral Interface BusDescription

Referring now to FIG. 28, there is illustrated a block diagram of theSPI The Serial Peripheral Interface (SPI) provides access to afour-wire, full-duplex, serial bus. SPI supports the connection ofmultiple slave devices to a master device on the same bus. A separateslave-select signal (NSS) is used to select a slave device and enable adata transfer between the master and the selected slave. Multiplemasters on the same bus are also supported. Collision detection isprovided when two or more masters attempt a data transfer at the sametime. The SPI can operate as either a master or a slave, as illustratedin the Interconnection scheme of FIG. 29. Data may be transferred at upto a maximum bit rate of one-eight the system clock frequency.

The four signals used by the SPI on lines 800 (MOSI, MISO, SCK, NSS) aredescribed below.

The master-out, slave-in (MOSI) signal is an output from a master deviceand an input to slave devices. It is used to serially transfer data fromthe master to the slave. Data is transferred most-significant bit first.

The master-in, slave-out (MISO) signal is an output from a slave deviceand an input to the master device. It is used to serially transfer datafrom the slave to the master. Data is transferred most-significant bitfirst. A SPI slave places the MISO pin in a high-impedance state whenthe slave is not selected.

The serial clock (SCK) signal is an output from the master device and aninput to slave devices. It is used to synchronize the transfer of databetween the master and slave on the MOSI and MISO lines.

The slave select (NSS) signal is an input used to select the SPI modulewhen in slave mode by a master, or to disable the SPI module when inmaster mode. When in slave mode, it is pulled low to initiate a datatransfer and remains low for the duration of the transfer.

Operation

Only a SPI master device can initiate a data transfer. The SPI is placedin master mode by setting the Master Enable flag (MSTEN, SPI0CN.1).Writing a byte of data to the SPI data register (SPI0DAT) 800 (Table 60)when in Master Mode starts a data transfer. The SPI master immediatelyshifts out the data serially on the MOSI line while providing the serialclock on SCK. The SPIF (SPI0CN.7) flag from register 804 (Table 58) isset to logic 1 at the end of the transfer. If interrupts are enabled, aninterrupt request is generated when the SPIF flag is set. The SPI mastercan be configured to shift in/out from one to eight bits in a transferoperation in order to accommodate slave devices with different wordlengths. The SPIFRS bits in an SPI Configuration Register 806 (Table 57)(SPI0CFG[2:0]) are used to select the number of bits to shift in/out ina transfer operation.

While the SPI master transfers data to a slave on the MOSI line, theaddressed SPI slave device simultaneously transfers the contents of itsshift register to the SPI master on the MISO line in a full-duplexoperation. The data byte received from the slave replaces the data inthe master's data register. Therefore, the SPIF flag serves as both atransmit-complete and receive-data-ready flag. The data transfer in bothdirections is synchronized with the serial clock generated by themaster. FIG. 30 illustrates the full-duplex operation of an SPI masterand an addressed slave.

The SPI data register is double buffered on reads, but not on a write.If a write to SPI0DAT 802 is attempted during a data transfer, the WCOLflag (SPI0CN.6) will be set to logic 1 and the write is ignored. Thecurrent data transfer will continue uninterrupted. A read of the SPIdata register by the system controller actually reads the receivebuffer. If the receive buffer still holds unread data from a previoustransfer when the last bit of the current transfer is shifted into theSPI shift register, a receive overrun occurs and the RXOVRN flag(SPI0CN.4) is set to logic 1. The new data is not transferred to thereceive buffer, allowing the previously received data byte to be read.The data byte causing the overrun is lost.

When the SPI is enabled and not configured as a master, it will operateas an SPI slave. Another SPI device acting as a master will initiate atransfer by driving the NSS signal low. The master then shifts data outof the shift register on the MISO pin using the serial clock. The SPIFflag is set to logic 1 at the end of a data transfer (when the NSSsignal goes high). The slave can load its shift register for the nextdata transfer by writing to the SPI data register. The slave must makethe write to the data register at least one SPI serial clock cyclebefore the master starts the next transmission. Otherwise, the byte ofdata already in the slave's shift register will be transferred.

Multiple masters may reside on the same bus. A Mode Fault flag (MODF,SPI0CN.5) is set to logic 1 when the SPI is configured as a master(MSTEN=1) and its slave select signal NSS is pulled low. In amultiple-master environment, the system controller should check thestate of the SLVSEL flag (SPI0CN.2) to ensure the bus is free beforesetting the MSTEN bit and initiating a data transfer.

Serial Clock Timing

As shown in FIG. 31, four combinations of serial clock phase andpolarity can be selected using the clock control bits in the SPIConfiguration Register (SPI0CFG) 806. The CKPHA bit (SPI0CFG.7) selectsone of two clock phases (edge used to latch the data). The CKPOL bit(SPI0CFG.6) selects between an active-high or active-low clock. Bothmaster and slave devices must be configured to use the same clock phaseand polarity. Note: the SPI should be disabled (by clearing the SPIENbit, SPI0CN.0) while changing the clock phase and polarity.

The SPI Clock Rate Register (SPI0CKR) 810 (Table 59) controls the mastermode serial clock frequency. This register is ignored when operating inslave mode.

SPI Special Function Registers

The SPI is accessed and controlled through four special functionregisters in the system controller: SPI0CN Control Register 800, SPI0DATData Register 802, SPI0CFG Configuration Register 806, and SPI0CKR ClockRate Register 810. UART

Description

Referring now to FIGS. 32A and 32B, there is illustrated a block diagramof the UART, which is capable of asynchronous transmission. The UART canfunction in full duplex mode. In all modes, receive data is buffered ina holding register. This allows the UART to start reception of a secondincoming data byte before software has finished reading the previousdata byte.

The UART has an associated Serial Control Register (SCON) 820 (Table 62)and a Serial Data Buffer (SBUF) 822 in the SFRs. The single SBUF 822location provides access to both transmit and receive registers. Readsaccess the Receive register and writes access the Transmit registerautomatically.

The UART is capable of generating interrupts if enabled. The UART hastwo sources of interrupts: a Transmit Interrupt flag, TI (SCON.1) setwhen transmission of a data byte is complete, and a Receive Interruptflag, RI (SCON.0) set when reception of a data byte is complete. TheUART interrupt flags are not cleared by hardware when the CPU vectors tothe interrupt service routine. They must be cleared manually bysoftware. This allows software to determine the cause of the UARTinterrupt (transmit complete or receive complete).

UART Operational Modes

The UART provides four operating modes (one synchronous and threeasynchronous) selected by setting configuration bits in the SCONregister. These four modes offer different baud rates and communicationprotocols. The four modes are summarized in Table 15.1 below. ModeSynchronization Baud Clock Data Bits Start/Stop Bits 0 Sync SYSCLK or ½1 ASync T1 on 72 Over 2 ASync SYSCLK/32 or 164 3 ASyncMode 0: Synchronous Mode

Mode 0 provides synchronous, half-duplex communication. Serial data istransmitted and received on the RX pin. The TX pin provides the shiftclock for both transmit and receive. The MCU must be the master since itgenerates the shift clock for transmission in both directions (FIG. 33illustrates this.)

Eight data bits are transmitted/received, LSB first (FIG. 34 illustratesthis timing diagram.) Data transmission begins when an instructionwrites a data byte to the SBUF register 822. The TI Transmit InterruptFlag (SCON.1) is set at the end of the eighth bit time. Data receptionbegins when the REN Receive Enable bit (SCON.4) is set to logic 1 andthe RI Receive Interrupt Flag (SCON.0) is cleared. One cycle after theeighth bit is shifted in, the FT flag is set and reception stops untilsoftware clears the RI bit. An interrupt will occur if enabled wheneither TI or RI are set.

Mode 1: 8-Bit UART, Variable Baud Rate

Mode 1 provides standard asynchronous, full duplex communication using atotal of 10 bits per data byte: one start bit, eight data bits (LSBfirst), and one stop bit; the timing diagram illustrated in FIG. 35.Data are transmitted from the TX pin and received at the RX pin. Onreceive, the eight data bits are stored in SBUF and the stop bit goesinto RB8 (SCON.2).

Data transmission begins when an instruction writes a data byte to theSBUF register. The TI Transmit Interrupt Flag (SCON.1) is set at the endof the transmission (the beginning of the stop-bit time). Data receptioncan begin any time after the REN Receive Enable bit (SCON.4) is set tologic 1. After the stop bit is received, the data byte will be loadedinto the SBUF receive register if the following conditions are met: RImust be logic 0, and if SM2 is logic 1, the stop bit must be logic 1.

If these conditions are met, the eight bits of data is stored in SBUF,the stop bit is stored in RB8 and the RI flag is set. If theseconditions are not met, SBUF and RB8 will not be loaded and the RI flagwill not be set. An interrupt will occur if enabled when either TI or RIare set.

The baud rate generated in Mode 1 is a function of timer overflow. TheUART can use either Timer 1 or Timer 2 operating in auto-reload mode togenerate the baud rate. On each timer overflow event (a rollover fromall ones—0xFF for Timer 1, 0xFFFF for Timer 2—to zero) a clock is sentto the baud rate circuit. This clock is divided by 16 to generate thebaud rate.

Timer 1 should be configured for 8-bit Counter/Timer with Auto-Reloadmode and its interrupt disabled when used as a baud rate generator. Thecombination of system clock frequency and the reload value stored in TH1determine the baud rate as follows:Mode 1 Baud Rate=(2^(SMOD)/32)*(SYSCLK*12^((TIM−1))/(256−TH1)).

The SMOD bit (PCON.7) selects whether or not to divide the Timer 1overflow rate by two. On reset, the SMOD bit is logic 0, thus selectingthe lower speed baud rate by default. Selecting the timebase used byTimer 1 allows further control of baud rate generation. Using the systemclock divided by one (setting TIM in CKCON) changes the twelve in thedenominator of the equation above to a one.

To use Timer 2 for baud rate generation, configure the timer Baud RateGenerator mode and set RCLK and/or TCLK to logic 1. Setting RCLK and/orTCLK automatically disables Timer 2 interrupts and configures Timer 2 touse the system clock divided by two as its timebase. If a differenttimebase is required, setting the C/T2 bit to logic 1 will allow thetimebase to be derived from a clock supplied to the external input pinT2. The combination of clock frequency and the reload value stored incapture registers determine the baud rate as follows:Mode 1 Baud Rate=SYSCLK/[32*(65536−[RCAP2H:RCAP2L])],where [RCAP2H:RCAP2L] is the 16-bit value held in the capture registers.Mode 2: 9-Bit UART, Fixed Baud Rate

Mode 2 provides asynchronous, full-duplex communication using a total ofeleven bits per data byte: a start bit, 8 data bits (LSB first), aprogrammable ninth data bit, and a stop bit, the timing diagram thereforillustrated in FIG. 37. On transmit, the ninth data bit is determined bythe value in TB8 (SCON.3). It can be assigned the value of the parityflag P in the PSW or used in multiprocessor communications. On receive,the ninth data bit goes into RB8 (SCON.2) and the stop bit is ignored.

Data transmission begins when an instruction writes a data byte to theSBUF register. The TI Transmit Interrupt Flag (SCON.1) is set at the endof the transmission (the beginning of the stop-bit time). Data receptioncan begin any time after the REN Receive Enable bit (SCON.4) is set tologic 1. After the stop bit is received, the data byte will be loadedinto the SBUF receive register if the following conditions are met: RImust be logic 0, and if SM2 is logic 1, the 9^(th) bit must be logic 1.

If these conditions are met, the eight bits of data is stored in SBUF,the ninth bit is stored in RB8 and the RI flag is set. If theseconditions are not met, SBUF and RB8 will not be loaded and the RI flagwill not be set. An interrupt will occur if enabled when either TI or RIare set.

The baud rate in Mode 2 is a direct function of the system clockfrequency as follows:Mode 2 Baud Rate=2^(SMOD)*(SYSCLK/64).

The SMOD bit (PCON.7) selects whether to divide SYSCLK by 32 or 64. Inthe formula, 2 is raised to the power SMOD, resulting in a baud rate ofeither 1/32 or 1/64 of the system clock frequency. On reset, the SMODbit is logic 0, thus selecting the lower speed baud rate by default.

Mode 3: 9-Bit UART, Variable Baud Rate

Mode 3 is the same as Mode 2 in all respects except the baud rate isvariable. The baud rate is determined in the same manner as for Mode 1.Mode 3 operation transmits 11 bits: a start bit, 8 data bits (LSBfirst), a programmable ninth data bit, and a stop bit. Timer 1 or Timer2 overflows generate the baud rate just as with Mode 1. In summary, Mode3 transmits using the same protocol as Mode 2 but with Mode 1 baud rategeneration.

The Timer Mode Register (T2CON) 824 is illustrated in Table 64.

Multiprocessor Communications

Modes 2 and 3 support multiprocessor communication between a masterprocessor and one or more slave processors by special use of the ninthdata bit, as illustrated in FIG. 38. When a master processor wants totransmit to one or more slaves, it first sends an address byte to selectthe target(s). An address byte differs from a data byte in that itsninth bit is logic 1; in a data byte, the ninth bit is always set tologic 0.

Setting the SM2 bit (SCON.5) of a slave processor configures its UARTsuch that when a stop bit is received, the UART will generate aninterrupt only if the ninth bit is logic one (RB8=1) signifying anaddress byte has been received. In the UART's interrupt handler,software will compare the received address with the slave's own assigned8-bit address. If the addresses match, the slave will clear its SM2 bitto enable interrupts on the reception of the following data byte(s).Slaves that weren't addressed leave their SM2 bits set and do notgenerate interrupts on the reception of the following data bytes,thereby ignoring the data. Once the entire message is received, theaddressed slave resets its SM2 bit to ignore all transmissions until itreceives the next address byte.

Multiple addresses can be assigned to a single slave and/or a singleaddress can be assigned to multiple slaves, thereby enabling “broadcast”transmissions to more than one slave simultaneously. The masterprocessor can be configured to receive all transmissions or a protocolcan be implemented such that the master/slave role is temporarilyreversed to enable half-duplex transmission between the original masterand slave(s).

Timers

The Microcontroller 40 implements four counter/timers: three are 16-bitcounter/timers compatible with those found in the standard 8051, and oneis a 16-bit timer for use with the ADC, SMBus, or for general purposeuse. These can be used to measure time intervals, count external eventsand generate periodic interrupt requests. Timer 0 and Timer 1 are nearlyidentical and have four primary modes of operation. Timer 2 offersadditional capabilities not available in Timers 0 and 1. Timer 3 issimilar to Timer 2, but without the capture or Baud Rate Generatormodes. Table 65 illustrates the timers. TABLE 65 Timer 0 and Timer 1:Timer 2: Timer 3: 13-bit counter/timer 16-bit counter/timer with auto-16-bit timer with auto-reload reload 16-bit counter/timer 16-bitcounter/timer with capture 8-bit counter/timer with auto- Baud rategenerator reload two 8-bit counter/timers (Timer 0 only)

When functioning as a timer, the counter/timer registers are incrementedon each clock tick. Clock ticks are derived from the system clockdivided by either one or twelve as specified by the Timer Clock Selectbits (T2M-T0M) in CKCON. The twelve-clocks-per-tick option providescompatibility with the older generation of the 8051 family. Applicationsthat require a faster timer can use the one-clock-per-tick option.

When functioning as a counter, a counter/timer register is incrementedon each high-to-low transition at the selected input pin. Events with afrequency of up to one-fourth the system clock's frequency can becounted. The input signal need not be periodic, but it should be held ata given level for at least two full system clock cycles to ensure thelevel is sampled.

Timer 0 and Timer 1

Timer 0 and Timer 1 are accessed and controlled through SFRs. Eachcounter/timer is implemented as a 16-bit register accessed as twoseparate bytes: a low byte (TL0 or TL1) and a high byte (TH0 or TH1).The Counter/Timer Control (TCON) register 830 (Table 66) is used toenable Timer 0 and Timer 1 as well as indicate their status. Bothcounter/timers operate in one of four primary modes selected by settingthe Mode Select bits M1-M0 in the Counter/Timer Mode (TMOD) register.Each timer can be configured independently. Following is a detaileddescription of each operating mode.

Mode 0: 13-Bit Counter/Timer

Timer 0 and Timer 1 operate as a 13-bit counter/timer in Mode 0. Thefollowing describes the configuration and operation of Timer 0,illustrated in FIG. 39. However, both timers operate identically andTimer 1 is configured in the same manner as described for Timer 0.

The TH0 register holds the eight MSBs of the 13-bit counter/timer. TL0holds the five LSBs in bit positions TL0.4-TL0.0. The three upper bitsof TL0 (TL0.7-TL0.5) are indeterminate and should be masked out orignored when reading. As the 13-bit timer register increments andoverflows from 0x1FFF (all ones) to 0x0000, the timer overflow flag TF0(TCON.5) is set and an interrupt will occur if enabled.

The C/T0 bit (TMOD.2) selects the counter/timer's clock source. ClearingC/T selects the system clock as the input for the timer. When C/T0 isset to logic 1, high-to-low transitions at the selected input pinincrement the timer register. (Refer to Port I/O Section _Ref472922989˜for information on selecting and configuring external I/O pins.)

Setting the TR0 bit (TCON.4) enables the timer when either GATE0(TMOD.3) is 0 or the input signal /INT0 is logic-level one. SettingGATE0 to logic 1 allows the timer to be controlled by the external inputsignal /INT0, facilitating pulse width measurements. Table 67illustrates the TR0 bit/Gate lists. TABLE 67 TR0 GATE0 /INT0Counter/Timer 0 X X Disabled 1 0 X Enable 1 1 0 Disable 1 1 1 EnableX = Don't CareSetting TR0 does not reset the timer register. The timer register shouldbe initialized to the desired value before enabling the timer.

TL1 and TH1 form the 13-bit register for Timer 1 in the same manner asdescribed above for TL0 and TH0. Timer 1 is configured and controlledusing the relevant TCON and TMOD bits just as with Timer 0.

Mode 1: 16-Bit Counter/Timer

Mode 1 operation is the same as Mode 0, except that the counter/timerregisters use all 16 bits. The counter/timers are enabled and configuredin Mode 1 in the same manner as for Mode 0.

Mode 2: 8-Bit Counter/Timer with Auto-Reload

Mode 2 configures Timer 0 and Timer 1 to operate as 8-bit counter/timerswith automatic reload of the start value, and is illustrated in FIG. 40.The TL0 holds the count and TH0 holds the reload value. When the counterin TL0 overflows from all ones to 0x00, the timer overflow flag TF0(TCON.5) is set and the counter in TL0 is reloaded from TH0. If enabled,an interrupt will occur when the TF0 flag is set. The reload value inTH0 is not changed. TL0 must be initialized to the desired value beforeenabling the timer for the first count to be correct. When in Mode 2,Timer 1 operates identically to Timer 0. Both counter/timers are enabledand configured in Mode 2 in the same manner as Mode 0.

Mode 3: Two 8-Bit Counter/Timers (Timer 0 Only)

Timer 0 and Timer 1 behave differently in Mode 3. Timer 0 is configuredas two separate 8-bit counter/timers held in TL0 and TH0, and isillustrated in FIG. 41. The counter/timer in TL0 is controlled using theTimer 0 control/status bits in TCON and TMOD: TR0, C/T0, GATE0 and TF0.It can use either the system clock or an external input signal as itstimebase. The TH0 register is restricted to a timer function sourced bythe system clock. TH0 is enabled using the Timer 1 run control bit TR1.TH0 sets the Timer 1 overflow flag TF1 on overflow and thus controls theTimer 1 interrupt.

Timer 1 is inactive in Mode 3, so with Timer 0 in Mode 3, Timer 1 can beturned off and on by switching it into and out of its Mode 3. When Timer0 is in Mode 3, Timer 1 can be operated in Modes 0, 1 or 2, but cannotbe clocked by external signals nor set the TF1 flag and generate aninterrupt. However, the Timer 1 overflow can be used for baud rategeneration.

The Timer 0 and Timer 1 operations are illustrated in Tables 70-73.

Timer 2

Timer 2 is a 16-bit counter/timer formed by the two 8-bit SFRs: TL2 (lowbyte) and TH2 (high byte). As with Timers 0 and 1, Timer 2 can useeither the system clock or transitions on an external input pin as itsclock source. The Counter/Timer Select bit C/T2 bit (T2CON.1) selectsthe clock source for Timer 2. Clearing C/T2 selects the system clock asthe input for the timer (divided by either one or twelve as specified bythe Timer Clock Select bit T2M in CKCON). When C/T2 is set to 1,high-to-low transitions at the T2 input pin increment the counter/timerregister. (Refer to Section _Ref473447873˜ for information on selectingand configuring external I/O pins.) Timer 2 can also be used to start anADC Data Conversion (see Section _Ref473448409˜).

Timer 2 offers capabilities not found in Timer 0 and Timer 1. Itoperates in one of three modes: 16-bit Counter/Timer with Capture,16-bit Counter/Timer with Auto-Reload or Baud Rate Generator Mode. Timer2's operating mode is selected by setting configuration bits in theTimer 2 Control (T2CON) register (Table 74). Below is a summary of theTimer 2 operating modes and the T2CON bits used to configure thecounter/timer. Detailed descriptions of each mode follow in Table 68.TABLE 68 RCLK TCLK CP/RL2 TR2 Mode 0 0 1 1 16-bit Counter/Timer withCapture 0 0 0 1 16-bit Counter/Timer with Auto- Reload 0 1 X 1 Baud RateGenerator 1 0 X 1 Baud Rate Generator 1 1 X 1 Baud Rate Generator X X X0 OffMode 0: 16-Bit Counter/Timer with Capture

In this mode, illustrated in FIG. 42, Timer 2 operates as a 16-bitcounter/timer with capture facility. A high-to-low transition on theT2EX input pin would cause the 16-bit value in Timer 2 (TH2 838, TL2838) to be loaded into the capture registers (RCAP2H 840, RCAP2L 842).

Timer 2 can use either SYSCLK, SYSCLK divided by 12, or high-to-lowtransitions on the T2 input pin as its clock source when operating inCounter/Timer with Capture mode. Clearing the C/T2 bit (T2CON.1) selectsthe system clock as the input for the timer (divided by one or twelve asspecified by the Timer Clock Select bit T2M in CKCON 844 (Table 69)).When C/T2 is set to logic 1, a high-to-low transition at the T2 inputpin increments the counter/timer register. As the 16-bit counter/timerregister increments and overflows from 0xFFFF to 0x0000, the TF2 timeroverflow flag (T2CON.7) is set and an interrupt will occur if theinterrupt is enabled.

Counter/Timer with Capture mode is selected by setting theCapture/Reload Select bit CP/RL2 (T2CON.0) and the Timer 2 Run Controlbit TR2 (T2CON.2) to logic 1. The Timer 2 External Enable EXEN2(T2CON.3) must also be set to logic 1 to enable a capture. If EXEN2 iscleared, transitions on T2EX will be ignored.

Mode 1: 16-bit Counter/Timer with Auto-Reload

The Counter/Timer with Auto-Reload mode sets the TF2 timer overflow flagwhen the counter/timer register overflows from 0×FFFF to 0x0000,illustrated in FIG. 43. An interrupt is generated if enabled. Onoverflow, the 16-bit value held in the two capture registers (RCAP2H,RCAP2L) is automatically loaded into the counter/timer register and thetimer is restarted.

Counter/Timer with Auto-Reload mode is selected by clearing the CP/RL2bit. Setting TR2 to logic 1 enables and starts the timer. Timer 2 canuse either the system clock or transitions on an external input pin asits clock source, as specified by the C/T2 bit. If EXEN2 is set to logic1, a high-to-low transition on T2EX will also cause Timer 2 to bereloaded. If EXEN2 is cleared, transitions on T2EX will be ignored.

16.2.3. Mode 2: Baud Rate Generator

Timer 2 can be used as a baud rate generator for the serial port (UART)when the UART is operated in modes 1 or 3, illustrated in FIG. 44. InBaud Rate Generator mode, Timer 2 works similarly to the auto-reloadmode. On overflow, the 16 bit value held in the two capture registers(RCAP2H, RCAP2L) is automatically loaded into the counter/timerregister. However, the TF2 overflow flag is not set and no interrupt isgenerated. Instead, the overflow event is used as the input to theUART's shift clock. Timer 2 overflows can be used to generate baud ratesfor transmit and/or receive independently.

The Baud Rate Generator mode is selected by setting RCLK (T2CON.5)and/or TCLK (T2CON.4) to logic one. When RCLK or TCLK is set to logic 1,Timer 2 operates in the auto-reload mode regardless of the state of theCP/RL2 bit. The baud rate for the UART, when operating in mode 1 or 3,is determined by the Timer 2 overflow rate:Baud Rate=Timer 2 Overflow Rate/16.

Note, in all other modes, the timebase for the timer is the system clockdivided by one or twelve as selected by the T2M bit in CKCON. However,in Baud Rate Generator mode, the timebase is the system clock divided bytwo. No other divisor selection is possible. If a different time base isrequired, setting the C/T2 bit to logic 1 will allow the timebase to bederived from the external input pin T2. In this case, the baud rate forthe UART is calculated as:Baud Rate=FCLK/[32*(65536−[RCAP2H:RCAP2L])]Where FCLK is the frequency of the signal (TCLK) supplied to T2 and[RCAP2H:RCAP2L] is the 16-bit value held in the capture registers.

As explained above, in Baud Rate Generator mode, Timer 2 does not setthe TF2 overflow flag and therefore cannot generate an interrupt.However, if EXEN2 is set to logic 1, a high-to-low transition on theT2EX input pin will set the EXF2 flag and a Timer 2 interrupt will occurif enabled. Therefore, the T2EX input may be used as an additionalexternal interrupt source.

The Timer 2 Capture Registers are illustrated in Tables 75-78.

Programmable Counter Array

Description

The Programmable Counter Array (PCA) provides enhanced timerfunctionality while requiring less CPU intervention than the standard8051 counter/timers. The PCA consists of a dedicated 16-bitcounter/timer and five 16-bit capture/compare modules. Eachcapture/compare module has its own associated I/O line (CEXn) which isrouted through the Crossbar to Port I/O when enabled (referring back toFIG. 7). The counter/timer is driven by a configurable timebase that canselect between four inputs as its source: system clock divided bytwelve, system clock divided by four, Timer 0 overflow, or an externalclock signal on the ECI line. The PCA is configured and controlledthrough the system controller's Special Function Registers.

Capture/Compare Modules

Each module can be configured to operate independently in one of fouroperation modes: Edge-triggered Capture, Software Timer, High SpeedOutput, or Pulse Width Modulator. Each module has Special FunctionRegisters (SFRs) associated with it in the Microcontroller 40 systemcontroller. These registers are used to exchange data with a module andconfigure the module's mode of operation.

Table 80 summarizes the bit settings in the PCA0CPMn registers used toplace the PCA capture/compare modules into different operating modes.Setting the ECCFn bit in a PCA0CPMn register enables the module's CCFninterrupt. Note: PCA0 interrupts must be globally enabled beforeindividual CCFn interrupts are recognized. PCA0 interrupts are globallyenabled by setting the EA bit (IE.7) and the EPCA0 bit (EIE1.3) tologic 1. FIG. 46 illustrates the PCA interrupt configuration. TABLE 80PCA0CPM Register Settings for PCA Capture/Compare Modules

X = Don't CareEdge-Triggered Capture Mode

In this mode, illustrated in FIG. 47 a valid transition on the CEXn pincauses the PCA to capture the value of the PCA counter/timer and load itinto the corresponding module's 16-bit capture/compare register(PCA0CPLn 850 and PCA0CPHn 852). The CAPPn and CAPNn bits in thePCA0CPMn register 854 are used to select the type of transition thattriggers the capture: low-to-high transition (positive edge),high-to-low transition (negative edge), or either transition (positiveor negative edge). When a capture occurs, the Capture/Compare Flag(CCFn) in PCA0CN 856 is set to logic 1 and an interrupt request isgenerated if CCF interrupts are enabled. The CCFn bit is notautomatically cleared by hardware when the CPU vectors to the interruptservice routine, and must be cleared by software.

Software Timer (Compare) Mode

In Software Timer mode, illustrated in FIG. 48, the PCA counter/timer iscompared to the module's 16-bit capture/compare register (PCA0CPHn andPCA0CPLn). When a match occurs, the Capture/Compare Flag (CCFn) inPCA0CN is set to logic 1 and an interrupt request is generated if CCFinterrupts are enabled. The CCFn bit is not automatically cleared byhardware when the CPU vectors to the interrupt service routine, and mustbe cleared by software. Setting the ECOMn and MATn bits in the PCA0CPMnregister 854 enables Software Timer mode.

High Speed Output Mode

In this mode, illustrated in FIG. 49, each time a match occurs betweenthe PCA Timer Counter and a module's 16-bit capture/compare register(PCA0CPHn 850 and PCA0CPLn 852) the logic level on the module'sassociated CEXn pin will toggle. Setting the TOGn, MATn, and ECOMn bitsin the PCA0CPMn register enables the High-Speed Output mode.

Pulse Width Modulator Mode

All of the modules can be used independently to generate pulse widthmodulated (PWM) outputs on their respective CEXn pin. The PWM mode isillustrated in FIG. 50. The frequency of the output is dependent on thetimebase for the PCA counter/timer. The duty cycle of the PWM outputsignal is varied using the module's PCA0CPLn capture/compare register.When the value in the low byte of the PCA counter/timer (PCA0L 858) isequal to the value in PCA0CPLn, the output on the CEXn pin will be set.When the count value in PCA0L overflows, the CEXn output will be reset.Also, when the counter/timer low byte (PCA0L) 858 overflows from 0xFF to0x00, PCA0CPLn is reloaded automatically with the value stored in thecounter/timer's high byte (PCA0H) 860 without software intervention.Setting the ECOMn and PWMn bits in the PCA0CPMn register enables PulseWidth Modulator mode.

PCA Counter/Timer

The 16-bit PCA counter/timer, illustrated in FIG. 51 consists of two8-bit SFRs: PCA0L 862 and PCA0H 864. PCA0H is the high byte (MSB) of the16-bit counter/timer and PCA0L is the low byte (LSB). Reading PCA0Lautomatically latches the value of PCA0H at the same time. By readingthe PCA0L Register first, this allows the PCA0H value to be held (at thetime PCA0L was read) until the user reads the PCA0H Register. ReadingPCA0H or PCA0L does not disturb the counter operation. The CPS1 and CPS0bits in the PCA0MD register 866 select the timebase for thecounter/timer.

When the counter/timer overflows from 0xFFFF to 0x0000, the CounterOverflow Flag (CF) in PCA0MD 866 is set to logic 1 and an interruptrequest is generated if CF interrupts are enabled. Setting the ECF bitin PCA0MD to logic 1 enables the CF flag to generate an interruptrequest. The CF bit is not automatically cleared by hardware when theCPU vectors to the interrupt service routine, and must be cleared bysoftware. (Note: PCA0 interrupts must be globally enabled before CFinterrupts are recognized. PCA0 interrupts are globally enabled bysetting the EA bit (IE.7) and the EPCA0 bit in EIE1 to logic 1.)Clearing the CIDL bit in the PCA0MD register allows the PCA to continuenormal operation while the microcontroller core is in Idle mode. Thecontrol register (PCA)CN) settings are set forth in Table 80 with thePCA0MD mode register settings illustrated in Table 81. CPS1 CPS0Timebase 0 0 System clock divided by 12 0 1 System clock divided by 4 10 Timer 0 overflow 1 1 High-to-low transitions on ECI (max rate = systemclock divided b 4)JTAG (IEEE 1149.1)Description

The MCU has an on-chip JTAG interface and logic to support boundary scanfor production and in-system testing, Flash read/write operations, andnon-intrusive in-circuit emulation. The JTAG interface is fullycompliant with the IEEE 1149.1 specification. Access of the JTAGInstruction Register (IR) and Data Registers (DR) are as described inthe Test Access Port and Operation of the IEEE 1149.1 specification.

The JTAG interface is via four dedicated pins on the MCU, which are TCK,TMS, TDI, and TDO.

The PCAOCPMn PCA Capture/Compare registers are illustrated in Table 82,with the PCA counter operation illustrated in Tables 83-86.

Through the 16-bit JTAG Instruction Register (IR), any of the eightinstructions shown in Table 87 can be commanded. There are three DR'sassociated with JTAG Boundary-Scan, and four associated with Flashread/write operations on the MCU.

Boundary Scan

The DR in the Boundary Scan path is an 87-bit shift register. TheBoundary DR provides control and observability of all the device pins aswell as the SFR bus and Weak Pullup feature via the EXTEST and SAMPLEcommands. TABLE 88 Boundary Data Register Bit Definitions Bit Action OnTarget 0 Capture Reset Enable from MCU Update Reset Enable to /RST pin 1Capture Reset input from /RST pin Update Reset output to /RST pin 2Capture External Clock from XTAL1 pin Update Not used 3 Capture Weakpullup enable to Port pins Update Weak pullup enable from MCU  4-11Capture SFR Address Bus bit from Microcontroller (e.g. Bit 4 = SFRA0,Bit5 = XSFRA1) Update SFR Address Bus bit to SFR Address Bus (e.g. Bit4= XSFRA0, Bit5 = XSFRA1 12-19 Capture SFR Data Bus bit read from SFR(e.g. Bit12 = SFRD0, Bit13 = SFRD1 . . . ) Update SFR Data Bus bitwritten to SFR (e.g. Bit12 = SFRD0, Bit13 = SFRD1 . . . ) 20 Capture SFRWrite Strobe from Microcontroller 40 Update SFR Write Strobe to SFR Bus21 Capture SFR Read Strobe from Microcontroller 40 Update SFR ReadStrobe to SFR Bus 22 Capture SFR Read/Modify/Write Strobe fromMicrocontroller 40 Update SFR Read/Modify/Write Strobe to SFR Bus 23,25, 27, Capture P0.n output enable from MCU (e.g. Bit23 = P0.0, Bit25 =P0.1, etc.) 29, 31, 33, 35, 37 Update P0.n output enable to pin (e.g.Bit23 = P0.0oe, Bit25 = P0.1oe, etc.) 24, 26, 28, Capture P0.n inputfrom pin (e.g. Bit24 = P0.0, Bit26 = P0.1, etc.) 30, 32, 34, 36, 38Update P0.n output to pin (e.g. Bit24 = P0.0, Bit26 = P0.1, etc.) 39,41, 43, Capture P1.n output enable from MCU (e.g. Bit39 = P1.0, Bit 41 =P1.1, etc.) 45, 47, 49, 51, 53 Update P1.n output enable to pin (e.g.Bit39 = P1.0oe, Bit41 = P1.1oe, etc.) 40, 42, 44, Capture P1.n inputfrom pin (e.g. Bit40 = P1.0, Bit42 = P1.1, etc.) 46, 48, 50, 52, 54Update P1.n output to pin (e.g. Bit40 = P1.0, Bit42 = P1.1, etc.) 55,57, 59, Capture P2.n output enable from MCU (e.g. Bit55 = P2.0, Bit57 =P2.1, etc.) 61, 63, 65, 67, 69 Update P2.n output enable to pin (e.g.Bit55 = P2.0oe, Bit57 = P2.1oe, etc.) 56, 58, 60, Capture P2.n inputfrom pin (e.g. Bit56 = P2.0, Bit58 = P2.1, etc.) 62, 64, 66, 68, 70Update P2.n output to pin (e.g. Bit56 = P2.0, Bit58 = P2.1, etc.) 71,73, 75, Capture P3.n output enable from MCU (e.g. Bit71 = P3.0, Bit73 =P3.1, etc.) 77, 79, 81, 83, 85 Update P3.n output enable to pin (e.g.Bit71 = P3.0oe, Bit73 = P3.1oe, etc.) 72, 74, 76, Capture P3.n inputfrom pin (e.g. Bit72 = P3.0, Bit74 = P3.1, etc.) 78, 80, 82, 84, 86Update P3.n output to pin (e.g. Bit72 = P3.0, Bit74 = P3.1, etc.)EXTEST provides access to both capture and update actions, while Sampleonly performs a capture.EXTEST Instruction

The EXTEST instruction is accessed via the IR. The Boundary DR providescontrol and observability of all the device pins as well as the SFR busand Weak Pullup feature. All on-chip latches are set to one.

SAMPLE Instruction

The SAMPLE instruction is accessed via the IR. The Boundary DR providesobservability and presetting of the scan-path latches.

BYPASS Instruction

The BYPASS instruction is accessed via the IR. It provides access to thestandard JTAG Bypass data register.

IDCODE Instruction

The IDCODE instruction is accessed via the IR. It provides access to the32-bit Device ID register. The Flash memory can be programmed directlyover the JTAG interface using the Flash Control, Flash Data, FlashAddress, and Flash Scale registers. These Data Registers are accessedvia the JTAG Instruction Register.

Emulation Support

The MCU has on-chip JTAG and emulation logic that provide non-intrusive,full speed, in-circuit emulation using the production part installed inthe end application using the four pin JTAG I/F. The emulation systemsupports inspection and modification of memory and registers,breakpoints, and single stepping. No additional target RAM, programmemory, or communications channels are required. All the digital andanalog peripherals are functional and work correctly (remain in sync)while emulating. The WDT is disabled when the MCU is halted duringsingle stepping or at a breakpoint.

Although the preferred embodiment has been described in detail, itshould be understood that various changes, substitutions and alterationscan be made therein without departing from the spirit and scope of theinvention as defined by the appended claims.

Table Appendix

TABLE 2 AMX0CF: AMUX Configuration Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value — — — — AIN67IC AIN45IC AIN23IC AIN01IC 00000000 Bit7Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0 × BA Bits7-4: UNUSED.Read 0000b; Write = don't care Bit3: AIN67IC: AIN6, AIN7 Input PairConfiguration Bit 0: AIN6 and AIN7 are independent singled-ended inputs1: AIN6, AIN7 are (respectively) +, − differential input pair Bit2:AIN45IC: AIN4, AIN5 Input Pair Configuration Bit 0: AIN4 and AIN5 areindependent singled-ended inputs 1: AIN4, AIN5 are (respectively) +, −differential input pair Bit1: AIN23IC: AIN2, AIN3 Input PairConfiguration Bit 0: AIN2 and AIN3 are independent singled-ended inputs1: AIN2, AIN3 are (respectively) +, − differential input pair Bit0:AIN01IC: AIN0, AIN1 Input Pair Configuration Bit 0: AIN0 and AIN1 areindependent singled-ended inputs 1: AIN0, AIN1 are (respectively) +, −differential input pair NOTE: The ADC Data Word is in 2's complementformat for channels configured as differential.

TABLE 3 AMX0SL: AMUX Channel Select Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value — — — — AMXAD3 AMXAD2 AMXAD1 AMXAD0 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0 × BB Bits7-4: UNUSED. Read= 0000b; Write = don't care Bits3-0: AMXAD3-0: AMUX Address Bits0000-1111: ADC Inputs selected per chart below AMXAD3-0 0000 0001 00100011 0100 0101 0110 0111 1xxx AMX0CF 00 AIN0 AIN1 AIN2 AIN3 AIN4 AIN5AIN6 AIN7 TEMP Bits SENSOR 3-0 01 +(AIN0) AIN2 AIN3 AIN4 AIN5 AIN6 AIN7TEMP −(AIN1) SENSOR 10 AIN0 AIN1 +(AIN2) AIN4 AIN5 AIN6 AIN7 TEMP−(AIN3) SENSOR 11 +(AIN0) +(AIN2) AIN4 AIN5 AIN6 AIN7 TEMP −(AIN1)−(AIN3) SENSOR 00 AIN0 AIN1 AIN2 AIN3 +(AIN4) AIN6 AIN7 TEMP −(AIN5)SENSOR 01 −(AIN0) AIN2 AIN3 +(AIN4) AIN6 AIN7 TEMP −(AIN1) −(AIN5)SENSOR 11 +(AIN0) +(AIN2) +(AIN4) AIN6 AIN7 TEMP −(AIN1) −(AIN3) −(AIN5)SENSOR 00 AIN0 AIN1 AIN2 AIN3 AIN4 AIN5 +(AIN6) TEMP −(AIN7) SENSOR 01+(AIN0) AIN2 AIN3 AIN4 AIN5 +(AIN6) TEMP −(AIN1) −(AIN7) SENSOR 10 AIN0AIN1 +(AIN2) AIN4 AIN5 +(AIN6) TEMP −(AIN3) −(AIN7) SENSOR 11 +(AIN0)+(AIN2) AIN4 AIN5 +(AIN6) TEMP −(AIN1) −(AIN3) −(AIN7) SENSOR 00 AIN0AIN1 AIN2 AIN3 +(AIN4) +(AIN6) TEMP −(AIN5) (−(AIN7) SENSOR 01 +(AIN0)AIN2 AIN3 +(AIN4) +(AIN6) TEMP −(AIN1) −(AIN5) −(AIN7) SENSOR 10 AIN0AIN1 +(AIN2) +(AIN4) +(AIN6) TEMP −(AIN3) −(AIN5) −(AIN7) SENSOR 11+(AIN0) +(AIN2) +(AIN4) +(AIN6) TEMP −(AIN1) −(AIN3) −(AIN5) −(AIN7)SENSOR

TABLE 4 ADC0CF: ADC Configuration Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value ADCSC2 ADCSC1 ADCSC0 — — AMPGN2 AMPGN1 AMPGN0 01100000Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0 × BC Bits7-5:ADCSC2-0: ADC SAR Conversion Clock Period Bits 000: SAR Conversion Clock× 1 System Clock 001: SAR Conversion Clock × 2 System Clocks 010: SARConversion Clock × 4 System Clocks 011: SAR Conversion Clock = 8 SystemClocks 1xx: SAR Conversion Clock = 16 Systems Clocks Bits4-3: UNUSED.Read 00b; Write = don't care Bits2-0: AMPGN2-0: ADC Internal AmplifierGain 000: Gain + 1 001: Gain + 2 010: Gain + 4 011: Gain + 8 11x: Gain +16 11x: Gain + 0.5

TABLE 5 ADC0CN: ADC Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value ADCEN ADCTM ADCINT ADBUSY ADSTM1 ADSTM0 ADWINT ADLIST00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: (bitaddressable) 0 × E8 Bit7: ADCEN: ADC Enable Bit 0: ABC Disabled. ADC isin low power shutdown. 1: ADC Enabled. ADC is active and ready for dataconversions. Bit6: ADCTM: ADC Track Mode Bit 0: When the ADC is enabled,tracking is always done unless a conversion is in process 1: TrackingDefined by ADSTM1-0 bits ADSTM1-0: 00: Tracking starts with the write of1 to ADBUSY and lasts for 3 SAR clocks 01: Tracking started by theoverflow of Timer 3 and last for 3 SAR clocks 10: ADC tracks only whenCNVSTR input is logic low 11: Tracking started by the overflow of Timer2 and last for 3 SAR clocks Bit5: ADCINT: ADC Conversion CompleteInterrupt Flag 0: ADC has not completed a data conversion since the lasttime this flag was cleared 1: ADC has completed a data conversion Bit4:ADBUSY: ADC Busy Bit Read 0: ADC Conversion complete or no valid datahas been converted since a reset. The falling edge of ADBUSY generatesan interrupt when enabled. 1: ADC Busy converting data Write 0: Noeffect 1: Starts ADC Conversion if ADSTM1-0 = 00b Bits3-2: ADSTM1-0: ADCStart of Conversion Mode Bits 00: ADC conversion started upon everywrite of 1 to ADBUSY 01: ADC conversions taken on every overflow ofTimer 3 10: ADC conversion started upon every rising edge of CNVSTR 11:ADC conversions taken on every overflow of Timer 2 Bit1: ADWINT: ADCWindow Compare Interrupt Flag 0: ADC Window Comparison Data match hasnot occurred 1: ADC Window Comparison Data match occurred Bit0: ADLJST:ADC Left Justify Data Bit 0: Data in ADC0H:ADC0L Registers is rightjustified 1: Data in ADC0H:ADC0L Registers is left justified

TABLE 6 ADC0H: ADC Data Word MSB Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress 0 × BF Bits7-0: ADC Data Word Bits For ADLJST = 1: Upper 8-bitsof the 12-bit ADC Data Word. For ADLJST = 0: Bits7-4 are the signextension of Bit3. Bits 3-0 are the upper 4-bits of the 12-bit ADC DataWord.

TABLE 7 ADC0L: ADC Data Word LSB Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0 × BE Bits7-0: ADC Data Word Bits For ADLJST = 1: Bits7-4 arethe lower 4-bits of the 12-bit ADC Data Word. Bits3-0 will always read0. For ADLJST = 0: Bits7-0 are the lower 8-bits of the 12-bit ADC DataWord. NOTE: Resulting 12-bit ADC Data Word appears in the ADC Data WordRegisters as follows: ADC0H[3:0]:ADC0L[7:0], if ADLJST = 0 (ADC0H[7:4]will be sign extension of ADC0H.3 if a differential reading, otherwise=0000b) ADC0H[7:0]:ADC0L[7:4], if ADLJST = 1 (ADC0L[3:0]= 0000b)EXAMPLE: ADC Data Word Conversion Map, AIN0 Input in Single-Ended Mode(AMX0CF = 0 × 00, AMX0SL = 00) ADC0H:ADC0L ADC0H:ADC0L AIN0 − AGND(Volts) ADLJST = 0) (ADLJST = 1) REF × (4095/4096) 0 × 0FFF 0 × FFF0 REF× ½ 0 × 0800 0 × 8000 REF × (2047/4096) 0 × 07FF 0 × 7FF0 EXAMPLE: ADCData Word Conversion Map, AIN0-AIN1 Differential Input Pair (AMX0CF =01, AMX0SL = 0 × 00) ADC0H:ADC0L ADC0H:ADC0L AIN0 − AIN1 (Volts) (ADLJST= 0 (ADLJST = 1) REF × (4095/4096) 0 × 07FF 0 × 7FF0 0 0× 0000 0 × 0000−REF × (1/4096) 0 × FFFF 0 × FFF0 −REF 0 × F800 0 × 8000

TABLE 8 DAC0H: DAC0 High Byte Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0 × D3 Bits7-0: DAC0 Data Word Most Significant Byte.

TABLE 9 DAC0L: DAC0 Low Byte Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0 × D2 Bits7-0: DAC0 Data Word Least Significant Byte.

TABLE 10 DAC0CN: DAC0 Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value DAC0EN — — — — DAC0DF2 DAC0DF1 DAC0DF0 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xD4 Bit7: DAC0EN: DAC0Enable Bit 0: DAC0 Disabled. DAC0 Output pin is tri-state; DAC0 is inlow power shutdown mode. 1: DAC0 Enabled, DAC0 Output is pin active;DAC0 is operational. Bits6-3: UNUSED. Read = 0000b; Write = don't careBits2-0: DAC0DF2-0: DAC0 Data Format Bits 000: The most significantnybble of the DAC0 Data Word is in DAC0H[3:0], while the leastsignificant byte is in DAC0L. DAC0H DAC0L MSB LSB 001: The mostsignificant 5-bits of the DAC0 Data Word is in DAC0H[4:0], while theleast significant 7-bits is in DAC0L[7:1]. DAC0H DAC0L MSB LSB 010: Themost significant 6-bits of the DAC0 Data Word is in DAC0H[5:0], whilethe least significant 6-bits is in DAC0L[7:2]. DAC0H DAC0L MSB LSB 011:The most significant 7-bits of the DAC0 Data Word is in DAC0H[6:0],while the least significant 5-bits is in DAC0L[7:3]. DAC0H DAC0L MSB LSB1xx: The most significant byte of the DAC0 Data Word is in DAC0H, whilethe least significant nybble is in DAC0L[7:4]. DAC0H DAC0L MSB LSB

TABLE 11 CPT0CN: Comparator 0 Control Register R/W R R/W R/W R/W R/W R/WR/W Reset Value CP0EN CP0OUT CP0RIF CP0FIF CP0HYP1 CP0HYP0 CP0HYN1CP0HYN0 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:0x9E Bit7: CP0EN: Comparator 0 Enable Bit 0: Comparator 0 Disabled. 1:Comparator 0 Enabled. Bit6: CP0OUT: Comparator 0 Output State Flag 0:Voltage on CP0+ < CP0− 1: Voltage on CP0+ > CP0− Bit5: CP0RIF:Comparator 0 Rising-Edge Interrupt Flag 0: No Comparator 0 Rising-EdgeInterrupt has occurred since this flag was cleared 1: Comparator 0Rising-Edge Interrupt has occurred since this flag was cleared Bit4:CP0FIF: Comparator 0 Falling-Edge Interrupt Flag 0: No Comparator 0Falling-Edge Interrupt has occurred since this flag was cleared 1:Comparator 0 Falling-Edge Interrupt has occurred since this flag wascleared Bit3-2: CP0HYP1-0: Comparator 0 Positive Hysteresis Control Bits00: Positive Hysteresis Disabled 01: Positive Hysteresis = 5 mV 10:Positive Hysteresis = 10 mV 11: Positive Hysteresis = 20 mV Bit1-0:CP0HYN1-0: Comparator 0 Negative Hysteresis Control Bits 00: NegativeHysteresis Disabled 01: Negative Hysteresis = 5 mV 10: NegativeHysteresis = 10 mV 11: Negative Hysteresis = 20 mV

TABLE 12 CPT1CN: Comparator 1 Control Register R/W R R/W R/W R/W R/W R/WR/W Reset Value CP1EN CP1OUT CP1RIF CP1FIF CP1HYP1 CP1HYP0 CP1HYN1CP1HYN0 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:0x9F Bit7: CP1EN: Comparator 1 Enable Bit 0: Comparator 1 Disabled. 1:Comparator 1 Enabled. Bit6: CP1OUT: Comparator 1 Output State Flag 0:Voltage on CP1+ < CP1− 1: Voltage on CP1+ > CP1− Bit5: CP1RIF:Comparator 1??Rising-Edge Interrupt Flag 0: No Comparator 1 Rising-Edgeinterrupt has occurred since this flag was cleared 1: Comparator 1Rising-Edge Interrupt has occurred since this flag was cleared Bit4:CP1FIF: Comparator 1 Falling-Edge Interrupt Flag 0: No Comparator 1Falling-Edge Interrupt has occurred since this flag was cleared 1:Comparator 1 Falling-Edge Interrupt has occurred since this flag wascleared Bit3-2: CP1HYP1-0: Comparator 1 Positive Hysteresis Control Bits00: Positive Hysteresis Disabled 01: Positive Hysteresis = 5 mV 10:Positive Hysteresis = 10 mV 11: Positive Hysteresis = 20 mV Bit1-0:CP1HYN1-0: Comparator 1 Negative Hysteresis Control Bits 00: NegativeHysteresis Disabled 01: Negative Hysteresis = 5 mV 10: NegativeHysteresis = 10 mV 11: Negative Hysteresis = 20 mV

TABLE 13 REF0CN: Reference Control Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value — — — — — TEMPE BIASE REFBE 00000000 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: 0xD1 Bits7-3: UNUSED. Read = 00000b;Write = don't care Bit2: TEMPE: Temperature Sensor Enable Bit 0:Internal Temperature Sensor Off. 1: Internal Temperature Sensor On.Bit1: BIASE: Internal Band-Gap Bias Enable Bit 0: Internal Band-Gap Off.1: Internal Band-Gap On. Bit0: REFBE: Internal Reference Buffer EnableBit 0: Internal Reference Buffer Off. System reference can be drivenfrom external source on VREF pin. 1: Internal Reference Buffer On.System reference from internal band-gap.

TABLE 15 PSW: Program Status Word R/W R/W R/W R/W R/W R/W R/W R/W ResetValue CY AC F0 RS1 RS0 OV F1 PARITY 00000000 Bit7 Bit6 Bit5 Bit4 Bit3Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0xD0 Bit7: CY: Carry FlagThis bit is set when the last arithmetic operation results in a carry(addition) or a borrow (subtraction). It is cleared to 0 by all otherarithmetic operations. Bit6: AC: Auxiliary Carry Flag. This bit is setwhen the last arithmetic operation results in a carry into (addition) ora borrow from (subtraction) the high order nibble. It is cleared to 0 byall other arithmetic operations. Bit5: F0: User Flag 0. This is abit-addressable, general purpose flag for use under software control.Bits4-3: RS1-RS0: Register Bank Select. These bits select which registerbank is used during register accesses. RS1 RS0 Register Bank Address 0 00 0x00-0x07 0 1 1 0x08-0x0F 1 0 2 0x10-0x17 1 1 3 0x18-0x1F Bit2: OV:Overflow Flag. This bit is set to 1 if the last arithmetic operationresulted in a carry (addition), borrow (subtraction), or overflow(multiply or divide). It is cleared to 0 by all other arithmeticoperations. Bit1: F1: User Flag 1. This is a bit-addressable, generalpurpose flag for use under software control. Bit0: PARITY: Parity Flag.This bit is set to 1 if the sum of the eight bits in the accumulator isodd and cleared if the sum is even.

TABLE 16 SP: Stack Pointer R/W R/W R/W R/W R/W R/W R/W R/W Reset Value00000111 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x81 Bits7-0: SP: Stack Pointer. The stack pointer holds the location of the topof the stack, The stack pointer is incremented before every PUSH oper-ation. The SP register defaults to 0x07 after reset.

TABLE 17 DPL: Data Pointer Low Byte R/W R/W R/W R/W R/W R/W R/W R/WReset Value 00000000 Bit7 Bit6 Bit5 BiT4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0x82 Bits 7-0: DPL: Data Pointer Low. The DPL register is thelow byte of the 16-bit DPTR. DPTR is used to access indirectly addessedRAM.

TABLE 18 DPH: Data Pointer High Byte R/W R/W R/W R/W R/W R/W R/W R/WReset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0x83 Bits 7-0: DPH: Data Pointer High. The DPH register is thehigh byte of the 16-bit DPTR. DPTR is used to access indirectlyaddressed RAM.

TABLE 19 ACC: Accumulator R/W R/W R/W R/W R/W R/W R/W R/W Reset ValueACC.7 ACC.6 ACC.5 ACC.4 ACC.3 ACC.2 ACC.1 ACC.0 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0xE0 Bits 7-0:ACC: Accumulator This register is the accumulator for arithmeticoperations.

TABLE 20 B: B Register R/W R/W R/W R/W R/W R/W R/W R/W Reset Value B.7B.6 B.5 B.4 B.3 B.2 B.1 B.0 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1Bit0 SFR Address: (bit addressable) 0xF0 Bits 7-0: B: B Register Thisregister serves as a second accumulator for certain arithmeticoperations.

TABLE 22 IE: Interrupt Enable R/W R/W R/W R/W R/W R/W R/W R/W ResetValue EA — ET2 ES ET1 EX1 ET0 EX0 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2Bit1 Bit0 SFR Address: (bit addressable) 0xAS Bit7: EA: Enable AllInterrupts. This bit globally enables/disables all interrupts. Itoverrides the individual interrupt mask settings. 0: Disable allinterrupt sources. 1: Enable each interrupt according to its individualmask setting. Bit6: UNUSED. Read = 0, Write = don't care Bit5: ET2:Enable Timer 2 Interrupt. This bit sets the masking of the Timer 2interrupt. 0: Disable all Timer 2 interrupts. 1: Enable interruptrequests generated by the TF2 flag (T2CON.7) Bit4: ES: Enable SerialPort (UART) Interrupt. This bit sets the masking of the Serial Port(UART) interrupt. 0: Disable all UART interrupts. 1: Enable interruptrequests generated by the R1 flag (SCON.0) or T1 flag (SCON.1). Bit3:ET1: Enable Timer 1 Interrupt. This bit sets the masking of the Timer 1interrupt. 0: Disable all Timer 1 interrupts. 1: Enable interruptrequests generated by the TF1 flag (TCON.7). Bit2: EX1: Enable ExternalInterrupt 1. This bit sets the masking of external interrupt 1. 0:Disable external interrupt 1. 1: Enable interrupt requests generated bythe /INT1 pin. Bit1: ET0: Enable Timer 0 Interrupt. This bit sets themasking of the Timer 0 interrupt. 0: Disable all Timer 0 interrupts. 1:Enable interruPt requests generated by the TF0 flag (TCON.5). Bit0: EX0:Enable External Interrupt 0. This bit sets the masking of externalinterrupt 0. 0: Disable external interrupt 0. 1: Enable interruptrequests generated by the /INT0 pin.

TABLE 23 IP: Interrupt Priority R/W R/W R/W R/W R/W R/w R/W R/W ResetValue — — PT2 PS PT1 PX1 PT0 PX0 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2Bit1 Bit0 SFR Address: (bit addressable) 0xB8 Bits7-6: UNUSED. Read =00b, Write = don't care. Bit5: PT2 Timer 2 Interrupt Priority ControlThis bit sets the priority of the Timer 2 interrupts. 0: Timer 2interrupt priority determined by default priority order. 1: Timer 2interrupts set to high priority level. Bit4: PS: Serial Port (UART)Interrupt Priority Control. This bit sets the priority of the SerialPort (UART) interrupts. 0: UART interrupt priority determined by defaultpriority order. 1: UART interrupts set to high priority level. Bit3:PT1: Timer 1 Interrupt Priority Control. This bit sets the priority ofthe Timer 1 interrupts. 0: Timer 1 interrupt priority determined bydefault priority order. 1: Timer 1 interrupts set to high prioritylevel. Bit2: PX1: External Interrupt 1 Priority Control. This bit setsthe priority of the External Interrupt 1 interrupts. 0: ExternalInterrupt 1 priority determined by default priority order. 1: ExternalInterrupt 1 set to high priority level. Bit1: PTO: Timer 0 InterruptPriority Control. This bit sets the priority of the Timer 0 interrupts.0: Timer 0 interrupt priority determined by default priority order. 1:Timer 0 interrupt set to high priority level. Bit0: PX0: ExternalInterrupt 0 Priority Control. This bit sets the priority of the ExternalInterrupt 0 interrupts. 0: External Interrupt 0 priority determined bydefault priority order. 1: External Interrupt 0 set to high prioritylevel.

TABLE 24 EIE1: Extended Interrupt Enable 1 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value ECP1R ECP1F ECP0R ECP0F EPCA0 EADC0 ESMB0 ESPI0 00000000Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SER Address: 0xE6 Bit7: ECP1R:Enable Comparator 1 (CP1) Rising Edge Interrupt. This bit sets themasking of the CP1 interrupt. 0: Disable CP1 Rising Edge interrupt. 1:Enable interrupt requests generated by the CP1RIF flag (CPT1CN.3). Bit6:ECP1F: Enable Comparator 1 (CP1) Falling Edge Interrupt. This bit setsthe masking of the CP1 interrupt. 0: Disable CP1 Falling Edge interrupt.1: Enable interrupt requests generated by the CP1FIF flag (CPT1CN.4).Bit5: ECP0R: Enable Comparator 0 (CP0) Rising Edge Interrupt. This bitsets the masking of the CP0 interrupt. 0: Disable CP0 Rising Edgeinterrupt. 1: Enable interrupt requests generated by the CP0RIF flag(CPT0CN.3). Bit4: ECP0F: Enable Comparator 0 (CP0) Falling EdgeInterrupt. This bit sets the masking of the CP0 interrupt. 0: DisableCP0 Falling Edge interrupt. 1: Enable interrupt requests generated bythe CP0FIF flag (CPT0CN.4). Bit3: EPCA0: Enable Programmable CounterArray (PCA0) Interrupt. This bit sets the masking of the PCA0interrupts. 0: Disable all PCA0 interrupts. 1: Enable interrupt requestsgenerated by PCA0. Bit2: EWADC0: Enable Window Comparison ADC0Interrupt. This bit sets the masking of ADC0 interrupts. 0: Disable ADC0Window Comparison Interrupt. 1: Enable Interrupt requests generated byADC0 Window Comparisons. Bit1: ESMB0: Enable SMBus 0 Interrupt. This bitsets the masking of the SMBus interrupt. 0: Disable all SMBusinterrupts. 1: Enable interrupt requests generated by the SI flag(SMB0CN.3). Bit0: ESPI0: Enable Serial Peripheral Interface 0 Interrupt.This bit set the masking, of SPI0 interrupt. 0: Disable all SPI0interrupts. 1: Enable Interrupt requests generated by the SPIF flag(SPI0CN.7).

TABLE 25 EIE2: Extended Interrupt Enable 2 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value EXVLD EJ EX7 EX6 EX5 EX4 EX3 ET3 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xE7 Bit7: EXVLD: Enable ExternalClock Source Valid (XLVD) Interrupt. This bit sets the masking of theXLVD interrupt. 0: Disable all XLVD interrupts. 1: Enable interruptrequests generated by the XLVD flag (OSCXCN.7) Bit6: EJ: Enable JTAGInterrupts. This bit sets the masking of the JTAG interrupt. 0: Disableall JTAG interrupts. 1: Enable interrupt requests generated by the JIflag (JTAG.X) Bit5: EX7: Enable External Interrupt 7. This bit sets themasking of External Interrupt 7. 0: Disable External Interrupt 7. 1:Enable interrupt requests generated by the External Interrupt 7 inputpin. Bit4: EX6: Enable External Interrupt 6. This bit sets the maskingof External Interrupt 6. 0: Disable External Interrupt 6. 1: Enableinterrupt requests generated by the External Interrupt 6 input pin.Bit3: EX5: Enable External Interrupt 5. This bit sets the masking ofExternal Interrupt 5. 0: Disable External Interrupt 5. 1: Enableinterrupt requests generated by the External Interrupt 5 input pin.Bit2: EX4: Enable External Interrupt 4. This bit sets the masking ofExternal Interrupt 4. 0: Disable External Interrupt 4. 1: Enableinterrupt requests generated by the External Interrupt 4 input pin.Bit1: EADC0: Enable ADC0 End of Conversion Interrupt. This bit sets themasking of the ADC0 End of Conversion Interrupt. 0: Disable ADC0Conversion interrupt. 1: Enable interrupt requests generated by the ADC0Conversion Interrupt. Bit0: ET3: Enable Timer 3 Interrupt. This bit setsthe masking of the Timer 3 interrupt. 0: Disable all Timer 3 interrupts.1: Enable interrupt requests generated by the TF3 flag (TMR3CN.7)

TABLE 26 EIP1: Extended Interrupt Priority 1 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value PCP1R PCP1F PCP0R PCP0F PPCA0 PADC0 PSMB0 PSPI0 00000000Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xF6 Bit7: PCP1R:Comparator 1 (CP1) Rising Interrupt Priority Control. This bit sets thepriority of the CP1 interrupt. 0: CP1 rising interrupt set to lowpriority level. 1: CP1 rising interrupt set to high priority level.Bit6: PCP1F: Comparator 1 (CP1) Falling Interrupt Priority Control. Thisbit sets the priority of the CP1 interrupt. 0: CP1 falling interrupt setto low priority level. 1: CP1 falling interrupt set to high prioritylevel. Bit5: PCP0R: Comparator 0 (CP0) Rising Interrupt Priority ControlThis bit sets the priority of the CP0 interrupt. 0: CP0 rising interruptset to low priority level. 1: CP0 rising interrupt set to high prioritylevel. Bit4: PCP0F: Comparator 0 (CP0) Falling Interrupt PriorityControl. This bit sets the priority of the CP0 interrupt. 0: CP0 fallinginterrupt set to low priority level. 1: CP0 falling interrupt set tohigh priority level. Bit3: PPCA0: Programmable Counter Array (PCA0)Interrupt Priori Control. This bit sets the priority of the PCA0interrupt. 0: PCA0 interrupt set to low priority level. 1: PCA0interrupt set to high priority level. Bit2: PADC0: Analog-to-DigitalConverter 0 (ADC0) Interrupt Priority Control. This bit sets thepriority of the ADC0 interrupt. 0: ADC0 interrupt set to low prioritylevel. 1: ADC0 interrupt set to high priority level. Bit1: PSMB0: SMBus0 Interrupt Priority Control. This bit sets the priority of the SMBusinterrupt. 0: SMBus interrupt set to low priority level. 1: SMBusinterrupt set to high priority level. Bit0: PSPI0: Serial PeripheralInterface 0 Interrupt Priority Control. This bit sets the priority ofthe SPI0 interrupt. 0: SPI0 interrupt set to low priority level. 1: SPI0interrupt set to high priority level.

TABLE 27 EIP2: Extended Interrupt Priority 2 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value PXVLD PEJ PX7 PX6 PX5 PX4 PX3 PT3 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xF7 Bit7: PXVLD: ExternalClock Source Valid (XVLD) Interrupt Priority Control. This bit sets thepriority of the XVLD interrupt. 0: XVLD interrupt set to low prioritylevel. 1: XVLD interrupt set to high priority level. Bit6: PEJ: JTAGInterrupt Priority Control. This bit sets the priority of the JTAGinterrupt. 0: JTAG interrupt set to low priority level. 1: JTAGinterrupt set to high priority level. Bit5: PX7: External Interrupt 7Priority Control. This bit sets the priority of the External Interrupt7. 0: External Interrupt 7 set to low priority level. 1: ExternalInterrupt 7 set to high priority level. Bit4: PX6: External Interrupt 6Priority Control. This bit sets the priority of the External Interrupt6. 0: External Interrupt 6 set to low priority level. 1: ExternalInterrupt 6 set to high priority level. Bit3: PX5: External Interrupt 5Priority Control. This bit sets the priority of the External Interrupt5. 0: External Interrupt 5 set to low priority level. 1: ExternalInterrupt 5 set to high priority level. Bit2: PX4: External Interrupt 4Priority Control. This bit sets the priority of the External Interrupt4. 0: External Interrupt 4 set to low priority level. I: ExternalInterrupt 4 set to high priority level. Bit1: PX3: External Interrupt 3Priority Control. This bit sets the priority of the External interrupt3. 0: External Interrupt 3 set to low priority level. 1: Externalinterrupt 3 set to high priority level. Bit0: PT3: Timer 3 InterruptPriority Control. This bit sets the priority of the Timer 3 interrupts.0: Timer 3 interrupt priority determined by default priority order. 1:Timer 3 interrupt set to high priority level.

TABLE 28 PCON: Power Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value SMOD — — — GF1 GF0 STOP IDLE 00000000 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: 0x87 Bit7: SMOD: Serial Port Baud RateDoubler Enable. 0: Serial Port baud rate is that defined by Serial PortMode in SCON. 1: Serial Port baud rate is double that defined by SerialPort Mode in SCON. Bits6-4: UNUSED. Read = 000b, Write = don't care.Bit3: GF1: General Purpose Flag 1. This is a general purpose flag foruse under software control. Bit2: GF0: General Purpose Flag 0. This is ageneral purpose flag for use under software control. Bit1: STOP: StopMode Select. Setting this bit will place the CIP-51 in Stop mode. Thisbit will always be read as 0. 1: Goes into power down mode. (Turns offoscillator). Bit0: IDLE: Idle Mode Select. Setting this bit will placethe CIP-51 in Idle mode. This bit will always be read as 0. 1: Goes intoidle mode. (Shuts off clock to CPU, but clock to Timers, Interrupts,Serial Ports, and Analog Peripherals are still active.)

TABLE 29 PSCTL: Program Store RW Control R/W R/W R/W R/W R/W R/W R/W R/WReset Value — — — — — — PSEE PSWE 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2Bit1 Bit0 SFR Address: 0xSF Bits7-2: UNUSED. Read = 000000b, Write =don't care. Bit1: PSEE: Program Store Erase Enable. Setting this bitallows an entire page of the Flash program memory to be erased. Aftersetting this bit, a write to Flash memory using the MOVX instructionwill erase the entire page that contains the location addressed by theMOVX instruction. The value of the data byte written does not matter. 0:Flash program memory erasure disabled. 1: Flash program memory erasureenabled. Bit0: PSWE: Program Store Write Enable. Setting this bit allowswriting a byte of data to the Flash program memory using the MOVXinstruction. The location must be erased before writing data. 0: Writeto Flash program memory disabled. 1: Write to Flash program memoryenabled.

TABLE 30 FLSCL: Flash Memory Timing Prescaler R/W R/W R/W R/W R/W R/WR/W R/W Reset Value FOSE FRAE — — FLASCL 10001111 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: 0xB6 Bit7: FOSE: Flash One-Shot TimerEnable (This is the timer which turns off the sense amps after readingthe Flash). 0: Flash One-shot timer disabled. 1: Flash One-shot timerenabled Bit6: FRAE: Flash Read Always Enable 0: Flash reads per one-shottimer 1: Flash always in read mode Bits5-4: UNUSED. Read = 00b, Write =don't care. Bits3-0: FLASCL: Flash Memory Timing Prescaler. Thisregister specifies the prescaler value for a given system clock requiredto generate the correct timing for Flash write/erase operations. If theprescaler is set to 111b, Flash write/erase operations are disabled.0000: System Clock < 50kHz 0001: 50kHz ≦ System Clock < 100kHz 0010:100kHz ≦ System Clock < 200kHz 0011: 200kHz ≦ System Clock < 400kHz0100: 400kHz ≦ System Clock < 800kHz 0101: 800kHz ≦ System Clock <1.6MHz 0110: 1.6Mhz ≦ System Clock < 3.2MHz 0111: 3.2MHz ≦ System Clock< 6.4MHz 1000: 6.4MHz ≦ System Clock < 12.8MHz 1001: 12.8MHz ≦ SystemClock < 20MHz 1010, 1011, 1100, 1101, 1110: Reserved Values 1111: FlashMemory Write/Erase Disabled The prescaler value is the smallest valuesatisfying the following equation: FLASCL > log_(2(System Clock/50kHz))

TABLE 31 FLACL: Flash Access Limit R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address 0xB7Bits 7-0: FLACL: Flash Memory Read Limit. This register holds the highbyte of the 16-bit program memory read limit address. The entire 16-bitaccess limit address value is calculated as 0xNN00 where NN is replacedby contents of FLACL. A write to this register sets the Flash AccessLimit. Any subsequent writes are ignored until until the next reset.

TABLE 32 WDTCN: Watchdog Timer Control Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value xxxxx111 Bit7 Bit6 Bits5 Bit4 Bit3 Bit2 Bit1 Bit0SFP Address: 0 × FF Bits7-0: WDT Control Writing 0 × A5 both enables andreloads the WDT. Writing 0 × DE followed within 4 clocks by 0 × ADdisables the WDT. Writing 0 × FF locks out the disable feature. Bit4:Watchdog Status Bit Reading the WDTCN.[4] bit indicates the WatchdogTimer Status. 0: WDT is inactive 1: WDT is active Bits2-0: WatchdogTimeout Interval Bits The WDTCN. [2:0] bits set the Watchdog TimeoutInterval. When writing these bits, WDTCN.7 must be set to 0.

TABLE 34 RSTSRC: Reset Source Register R R/W R/W R/W R R R/W R ResetValue JTAGRST CNVRSEF C0RSEF SWRSEF WDTRSF MCDRSF PORSF PINRSF xxxxxxxxBit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0 × EF (Note: Donot use read-modify-write operations on this register.) Bit7: JTAGRST.JTAG Reset Flag. 0: Source of prior reset was not from JTAG command. 1:Source of prior reset was from JTAG command. Bit6: CNVRSEF: ConvertStart Reset Source Enable and Flag Write 0: CNVSTR is not a reset source1: CNVSTR is a reset source (active low) Read 0: Source of prior resetwas not from CNVSTR 1: Source of prior reset was from CNVSTR Bit5:C0RSEF: Comparator 0 Reset Enable and Flag Write 0: Comparator 0 is nota reset source 1: Comparator 0 is a reset source Read 0: Source of priorreset was not from Comparator 0 1: Source of prior reset was fromComparator 0 Bit4: SWRSF: Software Reset Force and Flag Write 0: NoEffect 1: Forces an internal reset. /RST pin is not effected. Read 0:Prior reset source was not from write to the SWRSF bit. 1: Prior resetsource was from write to the SWRSF bit. Bit3: WDTRSF: Watchdog TimerReset Flag 0: Source of prior reset was not from WDT timeout. 1: Sourceof prior reset was from WDT timeout. Bit2: MCDRSF: Missing ClockDetector Flag 0: Source of prior reset was not from Missing ClockDetector timeout. 1: Source of prior reset was from Missing ClockDetector timeout. Bit 1: PORSF: Power-On Reset Force and Flag Write 0:No effect 1: Forces a Power-On Reset. /RST is driven low. Read 0: Sourceof prior reset was not from POR. 1: Source of prior reset was from POR.Bit0: PINRSF: HW Pin Reset Flag 0: Source of prior reset was not from/RST pin. 1: Source of prior reset was from /RST pin.

TABLE 36 OSCICN: Internal Oscillator Control Register R/W R/W R/W R/WR/W R/W R/W R/W Reset Value MSCLKE — — IFRDY CLKSL IOSCEN IFCN1 IFCN000000100 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0 × B2Bit7: MSCLKE: Missing Clock Enable Bit 0: Missing Clock DetectorDisabled 1: Missing Clock Detector Enabled; triggers a reset if amissing clock is detected Bits6-5: UNUSED. Read = 00b, Write = don'tcare Bit4: IFRDY: Internal Oscillator Frequency Ready Flag 0: InternalOscillator Frequency not running at speed specified by the IFCN bits. 1:Internal Oscillator Frequency running at speed specified by the IFCNbits. Bit3: CLKSL: System Clock Source Select Bit 0: Uses InternalOscillator as System Clock. 1: Uses External Oscillator as System Clock.Bit2: IOSCEN: Internal Oscillator Enable Bit 0: Internal OscillatorDisabled 1: Internal Oscillator Enabled Bits1-0: IFCN1-0: InternalOscillator Frequency Control Bits 00: Internal Oscillator typicalfrequency is 1.9 MHz. 01: Internal Oscillator typical frequency is 3.8MHz. 10: Internal Oscillator typical frequency is 7.5 MHz. 11: InternalOscillator typical frequency is 15 MHz.

TABLE 37 OSCXCN: External Oscillator Control Register R R/W R/W R/W R/WR/W R/W R/W Reset Value XTLVLD XOSCMD2 XOSCMD1 XOSCMD0 — XFCN2 XFCN1XFCN0 00110000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0 ×B1 Bit7: XTLVLD: Crystal Oscillator Valid Flag (Valid only when XOSCMD =11x.) 0: Crystal Oscillator is unused or not yet stable 1: CrystalOscillator is running and stable Bits6-4: XOSCMD2-0: External OscillatorMode Bits 00x: Off. XTAL1 pin is grounded internally. 010: System Clockfrom External CMOS Clock on XTAL1 pin. 011: System Clock from ExternalCMOS Clock on XTAL1 pin divided by 2. 10x: RC/C Oscillator Mode withdivide by 2 stage. 110: Crystal Oscillator Mode 111: Crystal OscillatorMode with divide by 2 stage. Bit3: RESERVED. Read = undefined, Write =don't care Bits2-0: XFCN2-0: External Oscillator Frequency Control Bits000-111: see table below XFCN Crystal (XOSCMD = 11x) RC (XOSCMD = 10x) C(XOSCMD = 10x) 000 Power Factor = 90 (10³) f ≦ 25 kHz K Factor = 0.741001 Power Factor = 280 (10³)   25 kHz < f ≦ 50 kHz K Factor = 2.36 010Power Factor = 810 (10³)   50 kHz < f ≦ 100 kHz K Factor = 7.10 011Power Factor = 2.30 (10⁶)  100 kHz < f ≦ 200 kHz K Factor = 21.0 100Power Factor = 6.30 (10⁶)  200 kHz < f ≦ 400 kHz K Factor = 60.8 101Power Factor = 20.4 (10⁶)  400 kHz < f ≦ 800 kHz K Factor = 225 110Power Factor = 36.6 (10⁶)  800 kHz < f ≦ 1.6 MHz K Factor = 773 111Power Factor = 110 (10⁶)  1.6 MHz < f ≦ 3.2 MHz K Factor <0 2141 CRYSTALMODE (Circuit from Error! Reference source not found., Option 1; XOSCMD= 11 x) Choose smallest Power Factor (PF) such that: PF > 5 * ESR * f² *C_(L) ^(2, where) ESR = crystal equivalent series resistance in ohms f =crystal frequency in MHz C_(L) = load capacitance in pF (crystalcapacitance, parasitic compensation network) RC MODE (Circuit fromError! Reference source not found., Option 2; XOSCMD = 10x) Chooseoscillation frequency range where: f = 1.23(10³) / (R * C), where f =frequency of oscillation in MHz C = capacitor value in pF R = Pull-upresistor value in kΩ C MODE (Circuit from Error! Reference source notfound., Option 3; XOSCMD = 10x) Choose K Factor (KF) for the oscillationfrequency desired: f = KF/ (C * AV+), where f = frequency of oscillationin MHz C = capacitor value on XTAL1, XTAL2 pins in pF

TABLE 39 XBR0: Port I/O CrossBar Register 0 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value CP0OEN ECIE PCA0ME UARTEN SPI0OEN SMB0OEN 00000000 Bit7Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xE1 Bit7: CP0OEN:Comparator 0 Output Enable Bit 0: CP0 unavailable at Port pin. 1: CP0routed to Port Pin. Bit6: ECIE: PCA0 Counter Input Enable Bit 0: ECIunavailable at Port pin. 1: ECI routed to Port Pin. Bits3-5: PCA0ME: PCAModule I/O Enable Bits 000: All PCA I/O unavailable at Port pins. 001:CEX0 routed to Port Pin. 010: CEX0, CEX1 routed to 2 Port Pins. 011:CEX0, CEX1, CEX2 routed to 3 Port Pins. 100: CEX0, CEX1, CEX2, CEX3routed to 4 Port Pins. 101: CEX0, CEX1, CEX2, CEX3, CEX4 routed to 5Port Pins. 110: RESERVED 111: RESERVED Bit2: UARTEN: UART I/O Enable Bit0: UART I/O unavailable at Port pins. 1: RX, TX routed to 2 Port Pins.Bit1: SPI0OEN: SPI Bus I/O Enable Bit 0: SPI I/O unavailable at Portpins. 1: MISO, MOSI, SCK, and NSS routed to 4 Port Pins. Bit0: SMB0OEN:SMBus Bus I/O Enable Bit 0: SMBus I/O unavailable at P0.0, P0.1. 1: SDArouted to P0.0, SCL routed to P0.1.

TABLE 40 XBR1: Port I/O CrossBar Register 1 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value SYSCKE T2EXE T2E INT1E T1E INT0E T0E CP1OE 00000000 Bit7Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xE2 Bit7: SYSCKE:SYSCLK Output Enable Bit 0: SYSCLK unavailable at Port pin. 1: SYSCLKoutput routed to Port Pin. Bit6: T2EXE: T2EX Enable Bit 0: T2EXunavailable at Port pin. 1: T2EX routed to Port Pin. Bit5: T2E: T2Enable Bit 0: T2 unavailable at Port pin. 1: T2 routed to Port Pin.Bit4: INT1E: /INT1 Enable Bit 0: /INT1 unavailable at Port pin. 1: /INT1routed to Port Pin. Bit3: T1E: T1 Enable Bit 0: T1 unavailable at Portpin. 1: T1 routed to Port Pin. Bit2: INT0E: /INT0 Enable Bit 0: /INT0unavailable at Port pin. 1: /INT0 routed to Port Pin. Bit1: T0E: T0Enable Bit 0: T0 unavailable at Port pin. 1: T0 routed to Port Pin.Bit0: CP1OE: Comparator 1 Output Enable Bit 0: CP1 unavailable at Portpin. 1: CP1 routed to Port Pin.

TABLE 41 XBR2: Port I/O CrossBar Register 2 R/W R/W R/W R/W R/W R/W R/WR/W Reset Value WEAKPU XBARE — — — — — CNVSTE 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xE3 Bit7: WEAKPU: Port I/O WeakPull-up Disable Bit 0: Weak Pull-ups Enabled 1: Weak Pull-ups DisabledBit6: XBARE: Crossbar Enable Bit 0: Crossbar Disabled 1: CrossbarEnabled Bits5-1: UNUSED. Read = 00000b, Write = don't care. Bit0:CNVSTE: ADC Convert Start Input Enable Bit 0: CNVSTR unavailable at Portpin. 1: CNVSTR routed to Port Pin. Example Usage of XBR0, XBR1, XBR2:When selected, the digital resources fill the Port I/O pins in order(top to bottom as shown in Error! Reference source not found.) startingwith P0.0 through P0.7, and then P1.0 through P1.7, and finally P2.0through P2.7. If the digital resources are not mapped to the Port I/Opins, they default to their matching internal Port Register bits.Example1: If XBR0 = 0x11, XBR1 = 0x00, and XBR2 = 0x40: P0.0=SDA,P0.1=SCL, P0.2=CEX0, P0.3=CEX1, P0.4 ...P2.7 map to corresponding PortI/O. Example2: If XBR0 = 0x80, XBR1 = 0x04, and XBR2 = 0x41: P0.0=CP0,P0.1=/INT0, P0.2 = CNVSTR, P0,3 ... P2.7 map to corresponding Port I/O.

TABLE 42 P0: Port0 Register R/W R/W R/W R/W R/W R/W R/W R/W Reset ValueP0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0 11111111 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0x80 Bits7-0:P0.[7:0] (Write - Output appears on I/O pins per XBR0, XBR1, and XBR2Registers) 0: Logic Low Output. 1: Logic High Output (open ifcorresponding PRT0CF.n bit = 0) (Read - Regardless of XBR0, XBR1, andXBR2 Register settings). 0: P0.n pin is logic low. 1: P0.n pin is logichigh.

TABLE 43 PRT0CF: Port0 Configuration Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bis0 SFRAddress 0xA4 Bits7-0: PRT0CF.[7:0]: Output Configuration Bits forP0.7-P0.0 (respectively) 0: Corresponding P0.n Output is Open-Drain. 1:Corresponding P0.n Output is Push-Pull.(Note:When SDA, SCL, and RN appear on any of the P0 I/O, each are open-drainregardless of the value of PRT0CF).

TABLE 44 P1: Port1 Register R/W R/W R/W R/W R/W R/W R/W R/W Reset ValueP1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0 11111111 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0x90 Bits7-0: P1[7:0](Write - Output appears on I/O pins per XBR0, XBR1, and XBR2 registers)0: Logic Low Output. 1: Logic High Output (open if correspondingPRT1CF.n bit = 0) (Read - Regardless of XBR0, XBR1, and XBR2 Registersettings). 0: P1.n pin is logic low. 1: P1.n pin is logic high.

TABLE 45 PRT1CF: Port1 Configuration Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress 0xA5 Bits7-0: PRT1CF.[7:0]: Output Configuration Bits forP1.7-P1.0 (respectively) 0: Corresponding P1.n Output is Open-Drain. 1:Corresponding P1.n Output is Push-Pull.

TABLE 46 PRT1IF: Porti Interrupt Flag Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value IE7 IE6 IE5 IE4 — — — — 00000000 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: 0xAD Bit7: IE7: External Interrupt 7Pending Flag. 0: No falling edge detected on P1.7. 1: This flag is setby hardware when a falling edge on P1.7 is detected. Bit6: IE6: ExternalInterrupt 6 Pending Flag. 0: No falling edge detected on P1.6. 1: Thisflag is set by hardware when a falling edge on P1.6 is detected. Bit5:IE5: External Interrupt 5 Pending Flag. 0: No falling edge detected onP1.5. 1: This flag is set by hardware when a falling edge on P1.5 isdetected. Bit4: IE4: External Interrupt 4 Pending Flag. 0: No fallingedge detected on P1.4. 1: This flag is set by hardware when a fallinedge on P1.4 is detected. Bits3-0: UNUSED. Read = 0000b, Write = don'tcare.

TABLE 47 P2: Port2 Register R/W R/W R/W R/W R/W R/W R/W R/W Reset ValueP2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0 11111111 Bit7 Bit6 Bit Bit4 Bit3BIt2 Bit1 Bit0 SFR Address: (bit addressable) 0xA0 Bits7-0: P2.[7:0](Write - Output appears on I/O pins per XBR0, XBR1, and XBR2 registers)0: Logic Low Output. 1: Logic High Output (open if correspondingPRT2CF.n bit = 0) (Read - Regardless of XBR0, XBR1, and XBR2 Registersettings). 0: P2.n is logic low. 1: P2.n is logic high.

TABLE 48 PRT2CF: Port2 Configuration Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xA6 Bits7-0: PRT2CF.[7:0]: Output Configuration Bits forP2.7-P2.0 (respectively) 0: Corresponding P2.n Output is Open-Drain. 1:Corresponding P2.n Output is Push-Pull.

TABLE 49 P3: Port3 Register R/W R/W R/W R/W R/W R/W R/W R/W Reset ValueP3.7 P3.6 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0 11111111 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0xB0 Bits7-0:P3.[7:0] (Write) 0: Logic Low Output. 1: Logic High Output (open ifcorresponding PRT3CF.n bit = 0) (Read) 0: P3.n is logic low. 1: P3.n islogic high.

TABLE 50 PRT3CF: Port3 Configuration Register R/W R/W R/W R/W R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xA7 Bits7-0: PRT3CF.[7:0]: Output Configuration Bits forP3.7-P3.0 (respectively) 0: Corresponding P3.n Output is Open-Drain. 1:Corresponding P3.n Output is Push-Pull.

TABLE 51 SMB0CN: SMBus Control Register R R/W R/W R/W R/W R/W R/W R/WReset Value BUSY ENSMB STA STO SI AA FTE TOE 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0xC0 Bit7: BUSY:Busy Status Flag. 0: SMBus is free 1: SMBus is busy Bit6: ENSMB: SMBusEnable. This bit enables/disables the SMBus serial interface. 0: SMBusdisabled. 1: SMBus enabled. Bit5: STA: SMBus Start Flag. 0: No STARTcondition is transmitted. 1: When operating as a master, a STARTcondition is transmitted if the bus is free. (If the bus is not free,the START is transmitted after a STOP is received.) If STA is set afterone or more bytes have been transmitted or received and before a STOP isreceived, a repeated START condition is transmitted. Bit4: STO: SMBusStop Flag. 0: No STOP condition is transmitted. 1: Setting STO to logic1 causes a STOP condition to be transmitted. When a STOP condition isreceived, hardware clears STO to logic 0. If both STA and STO are set, aSTOP condition is transmitted followed by a START condition. In slavemode, setting the STO flag causes SMBus to behave as if a STOP conditionwas received. Bit3: SI: SMBus Serial Interrupt Flag. This bit is set byhardware when one of 27 possible SMBus states is entered. (Status code0xF8 does not cause SI to be set.) When the SI interrupt is enabled,setting this bit causes the CPU to vector to the SMBus interrupt serviceroutine. This bit is not automatically cleared by hardware and must becleared by software. Bit2: AA: SMBus Assert Acknowledge Flag. This bitdefines the type of acknowledge returned during the acknowledge cycle onthe SCL line. 0: A “not acknowledge” (high level on SDA) is returnedduring the acknowledge cycle. 1: An “acknowledge” (low level on SDA) isreturned during the acknowledge cycle. Bit1: FTE: SMBus Free TimerEnable Bit 0: No timeout when SCL is high 1: Timeout when SCL high timeexceeds limit specified by the SMB0CR value. Bit0 TOE: SMBus TimeoutEnable Bit 0: No timeout when SCL is low. 1: Timeout when SCL low timeexceeds limit specified by Timer 3, if enabled.

TABLE 52 SMB0CR: SMBus Clock Rate Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xCF Bits7-0: SMB0CR.[7:0]: SMBus Clock Rate Preset The SMB0CRClock Rate register controls the frequency of the serial clock SCL inmaster mode. The 8-bit word stored in the SMB0CR Register preloads adedicated 8-bit timer. The timer counts up, and when it rolls over to0x00, the SCL logic state toggles. The period of the SCL clock is givenin the following equation: T_(H) = T_(L) = T_(SYSCLK) * [(256 −SMB0CR) + 2.5] ≧ 5usec Using the same value of SMB0CR from above, theBus Free Timeout period is given in the following equation: T_(BFT) =T_(SYSCLK) * [10*(256 − SMB0CR) + 1] ≧ 50usec

TABLE 53 SMB0DAT: SMBus Data Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xC2 Bits7-0: SMB0DAT: SMBus Data. The SMB0DAT registercontains a byte of data to be trans- mitted on the SMBus serialinterface or a byte that has just been received on the SMBus serialinterface. The CPU can read from or write to this register whenever theSI serial interrupt flag (SMB0CN.3) is set to logic one. The serial datain the register remains stable as long as the SI flag is set. When theSI flag is not set, the system may be in the process of shifting datain/out and the CPU should not attempt to access this register.

TABLE 54 SMB0ADR: SMBus Address Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value SLV6 SLV5 SLV4 SLV3 SLV2 SLV1 SLV0 GC 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xC3 Bits7-1: SLV6-SLV0:SMBus Slave Address. These bits are loaded with the 7-bit slave addressto which the SMBus will respond when operating as a slave transmitter orslave receiver. SLV6 is the most significant bit of the address andcorresponds to the first bit of the address byte received on the SMBus.Bit0: GC: General Call Address Enable. This bit is used to enablegeneral call address (0x00) recognition. 0: General call address isignored. 1: General call address is recognized.

TABLE 55 SMB0STA: SMBus Status Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value STA7 STA6 STA5 STA4 STA3 STA2 STA1 STA0 11111000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xC1 Bits7-3: STA7-STA3:SMBus Status Code. These bits contain the SMBus Status Code. There are28 possible status codes. Each status code corresponds to a single SMBusstate. A valid status code is present in SMB0STA when the SI flag(SMB0CN.3) is set. The content of SMB0STA is not defined when the SIflag is logic 0. Writing to the SMB0STA register at any time will yieldindeterminate results. Bits2-0: STA2-STA0: The three least significantbits of SMB0STA are always read as logic 0 when the SI flag is logic 1.

TABLE 57 SPI0CFG: SPI Configuration Register R/W R/W R R R R/W R/W R/WReset Value CKPHA CKPOL BC2 BC1 BC0 SPIFRS2 SPIFRS1 SPIFRS0 00000000Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x9A Bit7: CKPHA:SPI Clock Phase. This bit controls the SPI clock phase. 0: Data sampledon first edge ot SCK period. 1: Data sampled on second edge of SCKperiod. Bit6: CKPOL: SPI Clock Polarity This bit controls the SPI clockpolarity. 0: SCK line low in idle state. 1: SCK line high in idle state.Bits5-3: BC2-BC0: SPI Bit Count. Indicates which of the up to 8 bits ofthe SPI word have been transmitted. BC2-BC0 Bit Transmitted 0 0 0 Bit 0(LSB) 0 0 1 Bit 1 0 1 0 Bit 2 0 1 1 Bit 3 1 0 0 Bit 4 1 0 1 Bit 5 1 1 0Bit 6 1 1 1 Bit 7(MSB) Bits2-0: SPIFRS2-SPIFRS0: SPI Frame Size. Thesethree bits determine the number of bits to shift in/out of the SPI shiftregister during a data transfer in master mode. They are ignored inslave mode. SPIFRS Bits Shifted 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 51 0 1 6 1 1 0 7 1 1 1 8

TABLE 58 SPI0CN: SPI Control Register R/W R/W R/W R/W R R R/W R/W ResetValue SPIF WCOL MODE RXOVRN TXBSY SLVSEL MSTEN SPIEN 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xF8 Bit7: SPIF: SPIInterrupt Flag. This bit is set to logic 1 by hardware at the end of adata transfer. If interrupts are enabled, setting this bit causes theCPU to vector to the SPI0 interrupt service routine. This bit is notautomatically cleared by hardware. It must be cleared by software. Bit6:WCOL: Write Collision Flag. This bit is set to logic 1 by hardware (andgenerates a SPI interrupt) to indicate a write to the SPI data registerwas attempted while a data transfer was in progress. It is cleared bysoftware. Bit5: MODF: Mode Fault Flag. This bit is set to logic 1 byhardware (and generates a SPI interrupt) when a master mode collision isdetected (NSS is low and MSTEN = 1). This bit is not automaticallycleared by hardware. It must be cleared by software. Bit4: RXOVRN:Receive Overrun Flag. This bit is set to logic 1 by hardware (andgenerates a SPI interrupt) when the receive buffer still holds unreaddata from a previous transfer and the last bit of the current transferis shifted into the SPI shift register. This bit is not automaticallycleared by hardware, It must be cleared by software. Bit3: TXBSY:Transmit Busy Flag. This bit is set to logic 1 by hardware while amaster mode transfer is in progress. It is cleared by hardware at theend of the transfer. Bit2: SLVSEL: Slave Selected Flag. This bit is setto logic 1 whenever the NSS pin is low indicating it is enabled as aslave. It is cleared to logic 0 when NSS is high (slave disabled). Bit1:MSTEN: Master Mode Enable. 0: Disable master mode. Operate in slavemode. 1: Enable master mode. Operate as a master. Bit0: SPIEN: SPIEnable. This bit enables/disables the SPI. 0: SPI disabled. 1: SPIenabled.

TABLE 59 SPI0CKR: SPI Clock Rate Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value SCR7 SCR6 SCR5 SCR4 SCR3 SCR2 SCR1 SCR0 00000000 Bit7Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address 0x9D Bits7-0: SCR7-SCR0:SPI Clock Rate These bits determine the frequency of the SCK output whenthe SPI module is configured for master mode operation. The SCK clockfrequency is a divided down version of the system clock, and is given inthe following equations: f_(SCK) = 0.5 * f_(SYSCLK)/(SPI0CKR + 1), for 3<= SPI0CKR <= 255, f_(SCK) = f_(SYSCLK)/8, for 0 <= SPI0CKR <= 2.

TABLE 60 SPI0DAT: SPI Data Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value — — — — — — — — 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1Bit0 SFR Address: 0x9B Bits7-0: SPI0DAT: SPI0 Transmit and Receive Data.The SPI0DAT register is used to transmit and receive SPI data. Writingdata to SPI0DAT places the data immediately into the shift register andinitiates a transfer when in Master Mode. A read of SPI0DAT returns thecontents of the receive buffer.

TABLE 61 SBUF: Serial (UART) Data Buffer Register R/W R/W R/W R/W R/WR/W R/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0SFR Address: 0x99 Bits7-0: SBUF.[7:0]: Serial Data Buffer Bits 7-0(MSB-LSB) This is actually two registers; a transmit and a receivebuffer register. When data is moved to SBUF, it goes to the transmitbuffer and is held for serial transmission. Moving a byte to SBUF iswhat initiates the transmission. When data is moved from SBUF, it comesfrom the receive buffer.

TABLE 62 SCON: Serial Port Control Register R/W R/W R/W R/W R/W R/W R/WR/W Reset Value SM0 SM1 SM2 REN TB8 RB8 TI RI 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addresssble) 0x98 Bits7-6:SM0-SM1: Serial Port Operation Mode. These bits select the Serial PortOperation Mode. SM0 SM1 Mode 0 0 Mode 0: Synchronous Mode 0 1 Mode 1:8-Bit UART, Variable Baud Rate 1 0 Mode 2: 9-Bit UART, Fixed Baud Rate 11 Mode 3: 9-Bit UART, Variable Baud Rate Bit5: SM2: MultiprocessorCommunication Enable. The function of this bit is dependent on theSerial Port Operation Mode. Mode 0: No effect Mode 1: Checks for validstop bit. 0: Logic level of stop bit is ignored. 1: RI will only beactivated if stop bit is logic level 1. Mode 2 and 3: MultiprocessorCommunications Enable. 0: Logic level of ninth bit is ignored. 1: RI isset and an interrupt is generated only when the ninth bit is logic 1.Bit4: REN: Receive Enable. This bit enables/disables the UART receiver.0: UART reception disabled. 1: UART reception enabled. Bit3: TB8: NinthTransmission Bit. The logic level of this bit will be assigned to theninth transmission bit in Modes 2 and 3. It is not used in Modes 0and 1. Set or cleared by software as required. Bit2: RB8: Ninth ReceiveBit. The bit is assigned the logic level of the ninth bit received inModes 2 and 3. In Mode 1, if SM2 is logic 0, RB8 is assigned the logiclevel of the received stop bit. RB8 is not used in Mode 0. Bit1: TI:Transmit Interrupt Flag. Set by hardware when a byte of data has beentransmitted by the UART (after the 8^(th) bit in Mode 0, or at thebeginning of the stop bit in other modes). When the UART interrupt isenabled, setting this bit causes the CPU to vector to the UART interruptservice routine. This bit must be cleared manually by software Bit0: RI:Receive Interrupt Flag. Set by hardware when a byte of data has beenreceived by the UART (after the 8^(th) bit in Mode 0, or after the stopbit in other modes - see SM2 bit for exception). When the UART interruptis enabled, setting this bit causes the CPU to vector to the UARTinterrupt service routine. This bit must be cleared manually bysoftware.

TABLE 64 TCON: Timer Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 00000000 Bit7 Bit6 Bit5 Bit4Bit3 Bit2 Bit1 Bit0 SFR Address 0x88 Bit7: TF1: Timer 1 Overflow Flag.Set by hardware when Timer 1 overflows. This flag can be cleared bysoftware but is automatically cleared when the CPU vectors to the Timer1 interrupt service routine. 0: No Timer 1 overflow detected. 1: Timer 1has overflowed. Bit6: TR1: Timer 1 Run Control. 0: Timer 1 disabled. 1:Timer 1 enabled. Bit5: TF0: Timer 0 Overflow Flag. Set by hardware whenTimer 0 overflows. This flag can be cleared by software but isautomatically cleared when the CPU vectors to the Timer 0 interruptservice routine. 0: No Timer 0 overflow detected. 1: Timer 0 hasoverflowed. Bit4: TR0: Timer 0 Run Control. 0: Timer 0 disabled. 1:Timer 0 enabled. Bit3: IE1: External Interrupt 1. This flag is set byhardware when an edge/level of type defined by IT1 is detected. It canbe cleared by software but is automatically cleared when the CPU vectorsto the External Interrupt 1 service routine if IT1 = 1. This flag is theinverse of the /INT1 input signal's logic level when IT1 = 0. Bit2: IT1:Interrupt 1 Type Select. This bit selects whether the configured /INT1signal will detect falling edge or active-low level-sensitiveinterrupts. 0: /INT1 is level triggered. 1: /INT1 is edge triggered.Bit1: IE0: External Interrupt 0. This flag is set by hardware when anedge/level of type defined by IT0 is detected. It can be cleared bysoftware but is automatically cleared when the CPU vectors to theExternal Interrupt 0 service routine if IT0 = 1. This flag is theinverse of the /INT0 input signal's logic level when IT0 = 0. Bit0: IT0:Interrupt 0 Type Select. This bit selects whether the configured /INT0signal will detect falling edge or active-low level-sensitiveinterrupts. 0: /INT0 is level triggered. 1: /INT0 is edge triggered.

TABLE 66 TMOD: Timer Mode Register R/W R/W R/W R/W R/W R/W R/W R/W ResetValue GATE1 C/T1 T1M1 T1M0 GATE0 C/T0 T0M1 T0M0 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x89 Bit7: GATE1: Timer 1 GateControl. 0: Timer 1 enabled when TR1 = 1 irrespective of /INT1 logiclevel. 1: Timer 1 enabled only when TR1 = 1 AND /INT1 = logic level one.Bit6: C/T1: Counter/Timer 1 Select. 0: Timer Function: Timer 1incremented by clock defined by T1M bit (CKCON.4). 1: Counter Function:Timer 1 incremented by high-to-low transitions on external input pinBits5-4: T1M1-T1M0: Timer 1 Mode Select. These bits select the Timer 1operation mode. T1M1 T1M0 Mode 0 0 Mode 0: 13-bit counter/timer 0 1 Mode1: 16-bit counter/timer 1 0 Mode 2: 8-bit counter/timer with auto-reload1 1 Mode 3: Timer 1 Inactive Bit3: GATE0: Timer 0 Gate Control. 0: Timer0 enabled when TR0 = 1 irrespective of /INT0 logic level. 1: Timer 0enabled only when TR0 = 1 AND /INT0 = logic level one. Bit2: C/T0:Counter/Timer Select. 0: Timer Function: Timer 0 incremented by clockdefined by T0M bit (CKCON.3). 1: Counter Function: Timer 0 incrementedby high-to-low transitions on external input pin Bits1-0: T0M1-T0M0:Timer 0 Mode Select. These bits select the Timer 0 operation mode. T0M1T0M0 Mode 0 0 Mode 0: 13-bit counter/timer 0 1 Mode 1: 16-bitcounter/timer 1 0 Mode 2: 8-bit counter/timer with auto-reload 1 1 Mode3: Two 8-bit counter/timers

TABLE 69 CKCON: Clock Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value — — T2M T1M T0M — — — 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2Bit1 Bit0 SFR Address 0x8E Bits7-6: UNUSED. Read = 00b, Write = don'tcare. Bit5: T2M: Timer 2 Clock Select. This bit controls the division ofthe system clock supplied to Timer 2. This bit is ignored when the timeris in baud rate generator mode or counter mode (i.e. C/T2 = 1). 0: Timer2 uses the system clock divided by 12. 1: Timer 2 uses the system clock.Bit4: T1M: Timer 1 Clock Select. This bit controls the division of thesystem clock supplied to Timer 1. 0: Timer 1 uses the system clockdivided by 12. 1: Timer 1 uses the system clock. Bit3: T0M: Timer 0Clock Select. This bit controls the division of the system clocksupplied to Counter/Timer 0. 0: Counter/Timer uses the system clockdivided by 12. 1: Counter/Timer uses the system clock. Bits2-0: UNUSED.Read = 000b, Write = don't care.

TABLE 70 TL0: Timer 0 Low Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x8ABits 7-0: TL0: Timer 0 Low Byte. The TL0 register is the low byte of the16-bit Timer 0.

TABLE 71 TL1: Timer 1 Low Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x8BBits 7-0: TL1: Timer 1 Low Byte. The TL1 register is the low byte of the16-bit Timer 1.

TABLE 72 TH0: Timer 0 High Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bitt0 SFR Address:0x8C Bits 7-0: TH0: Timer 0 High Byte. The TH0 register is the high byteof the 16-bit Timer 0.

TABLE 73 TH1: Timer 1 High Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0x8DBits 7-0: TH1: Timer 1 High Byte. The TH1 register is the high byte ofthe 16-bit Timer 1.

TABLE 74 T2CON: Timer 2 Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2 00000000 Bit7 Bit6Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: (bit addressable) 0xC8 Bit7:TF2: Timer 2 Overflow Flag. Set by hardware when Timer 2 overflows from0xFFFF to 0x0000. When the Timer 2 interrupt is enabled, setting thisbit causes the CPU to vector to the Timer 2 interrupt service routine.This bit is not automatically cleared by hardware and must be cleared bysoftware. TF2 will not be set when RCLK and/or TCLK are logic 1. Bit6:EXF2: Timer 2 External Flag. Set by hardware when either a capture orreload is caused by a high-to-low transition on the T2EX input pin andEXEN2 is logic 1. When the Timer 2 interrupt is enabled, setting thisbit causes the CPU to vector to the Timer 2 Interrupt service routine.This bit is not automatically cleared by hardware and must be cleared bysoftware. Bit5: RCLK: Receive Clock Flag. Selects which timer is usedfor the UART's receive clock in modes 1 or 3. 0: Timer 1 overflows usedfor receive clock. 1: Timer 2 overflows used for receive clock. Bit4:TCLK: Transmit Clock Flag. Selects which timer is used for the UART'stransmit clock in modes 1 or 3. 0: Timer 1 overflows used for transmitclock. 1: Timer 2 overflows used for transmit clock. Bit3: EXEN2: Timer2 External Enable. Enables high-to-low transitions on T2EX to triggercaptures or reloads when Timer 2 is not operating in Baud Rate Generatormode. 0: High-to-low transitions on T2EX ignored. 1: High-to-lowtransitions on T2EX cause a capture or reload. Bit2: TR2: Timer RunControl. This bit enables/disables Timer 2. 0: Timer 2 disabled. 1:Timer 2 enabled. Bit1: C/T2: Counter/Timer Select. 0: Timer Function:Timer 2 incremented by clock defined by T2M (CKCON.5). 1: CounterFunction: Timer 2 incremented by high-to-low transitions on externalinput pin. Bit0: CP/RL2: Capture/Reload Select. This bit selects whetherTimer 2 functions in capture or auto-reload mode. EXEN2 must be logic 1for high-to-low transitions on T2EX to be recognized and used to triggercaptures or reloads. If RCLK or TCLK is set, this bit is ignored andTimer 2 will function in auto-reload mode. 0: Auto-reload on Timer 2overflow or high-to-low transition at T2EX (EXEN2 = 1). 1: Capture onhigh-to-low transition at T2EX (EXEN2 = 1).

TABLE 75 RCAP2L: Timer 2 Capture Register Low Byte R/W R/W R/W R/W R/WR/W R/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0SFR Address: 0xCA Bits 7-0: RCAP2L: Timer 2 Capture Register Low Byte.The RCAP2L register captures the low byte of Timer 2 when Timer 2 isconfigured in capture mode. When Timer 2 is configured in auto-reloadmode, it holds the low byte of the reload value.

TABLE 76 RCAP2H: Timer 2 Capture Register High Byte R/W R/W R/W R/W R/WR/W R/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0SFR Address: 0xCB Bits 7-0: RCAP2H: Timer 2 Capture Register High Byte.The RCAP2H register captures the high byte of Timer 2 when Timer 2 isconfigured in capture mode. When Timer 2 is configured in auto-reloadmode, it holds the high byte of the reload value.

TABLE 77 TL2: Timer 2 Low Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xCCBits 7-0: TL2: Timer 2 Low Byte. The TL2 register contains the low byteof the 16-bit Timer 2.

TABLE 78 TH2: Timer 2 High Byte R/W R/W R/W R/W R/W R/W R/W R/W ResetValue 00000000 Btt7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xCDBits 7-0: TH2: Timer 2 High Byte. The TH2 register contains the highbyte of the 16-bit Timer 2.

TABLE 80 PCA0CN: PCA Control Register R/W R/W R/W R/W R/W R/W R/W R/WReset Value CF CR — CCF4 CCF3 CCF2 CCF1 CCF0 00000000 Bit7 Bit6 Bit5Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xD8 Bit7: CF: PCA Counter/TimerOverflow Flag. Set by hardware when the PCA Counter/Timer overflows from0xFFFF to 0x0000. When the Counter/Timer Overflow (CF) interrupt isenabled, setting this bit causes the CPU to vector to the CF interruptservice routine. This bit is not automatically cleared by hardware andmust be cleared by software. Bit6: CR: PCA Counter/Timer Run Control.This bit enables/disables the PCA Counter/Timer. 0: PCA Counter/Timerdisabled. 1: PCA Counter/Timer enabled. Bit5: UNUSED. Read = 0, Write =don't care. Bit4: CCF4: PCA Module 4 Capture/Compare Flag. This bit isset by hardware when a match or capture occurs. When the CCF interruptis enabled, setting this bit causes the CPU to vector to the CCFinterrupt service routine. This bit is not automatically cleared byhardware and must be cleared by software. Bit3: CCF3: PCA Module 3Capture/Compare Flag. This bit is set by hardware when a match orcapture occurs. When the CCF interrupt is enabled, setting this bitcauses the CPU to vector to the CCF interrupt service routine. This bitis not automatically cleared by hardware and must be cleared bysoftware. Bit2: CCF2: PCA Module 2 Capture/Compare Flag. This bit is setby hardware when a match or capture occurs. When the CCF interrupt isenabled, setting this bit causes the CPU to vector to the CCF interruptservice routine. This bit is not automatically cleared by hardware andmust be cleared by software. Bit1: CCF1: PCA Module 1 Capture/CompareFlag. This bit is set by hardware when a match or capture occurs. Whenthe CCF interrupt is enabled, setting this bit causes the CPU to vectorto the CCF interrupt service routine. This bit is not automaticallycleared by hardware and must be cleared by software. Bit0: CCF0: PCAModule 0 Capture/Compare Flag. This bit is set by hardware when a matchor capture occurs. When the CCF interrupt is enabled, setting this bitcauses the CPU to vector to the CCF interrupt service routine. This bitis not automatically cleared by hardware and must be cleared bysoftware.

TABLE 81 PCA0MD: PCA Mode Register R/W R/W R/W R/W R/W R/W R/W R/W ResetValue CIDL — — — — CPS1 CPS0 ECF 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2Bit1 Bit0 SFR Address: 0xD9 Bit7: CIDL: PCA Counter/Timer Idle Control.Specifies PCA behavior when CPU is in Idle Mode. 0: PCA continues tofunction normally while the system controller is in Idle Mode. 1: PCAoperation is suspended while the system controller is in Idle Mode.Bits6-3: UNUSED. Read = 0000b, Write = don't care. Bits2-1: CPS1-CPS0:PCA Counter/Timer Pulse Select. These bits select the timebase sourcefor the PCA counter. CPS1 CPS0 Timebase 0 0 System clock divided by 12 01 System clock 1 0 Timer 0 overflow 1 1 High-to-low transitions on ECI(max rate = system clock divided by 4) Bit0: ECF: PCA Counter/TimerOverflow Interrupt Enable. This bit sets the masking of the PCACounter/Timer Overflow (CF) interrupt. 0: Disable the CF interrupt. 1:Enable a PCA Counter/Timer Overflow interrupt request when CF (PCA0CN.7)is set.

TABLE 82 PCA0CPMn: PCA Capture/Compare Registers R/W R/W R/W R/W R/W R/WR/W R/W Reset Value — ECOMn CAPPa CAPNn MATn TOGn PWMn ECCFn 00000000Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address: 0xDA-0xDE PCA0CPMnAddress: PCA0CPM0 = 0xDA (n = 0) PCA0CPM1 = 0xDB (n = 1) PCA0CPM2 = 0xDC(n = 2) PCA0CPM3 = 0xDD (n = 3) PCA0CPM4 = 0xDE (n = 4) Bit7: UNUSED.Read = 0, Write = don't care. Bit6: ECOMn: Comparator Function Enable.This bit enables/disables the comparator function for PCA module n. 0:Disabled. 1: Enabled. Bit5: CAPPn: Capture Positive Function Enable.This bit enables/disables the positive edge capture for PCA module n. 0:Disabled. 1: Enabled. Bit4: CAPNn: Capture Negative Function Enable.This bit enables/disables the negative edge capture for PCA module n. 0:Disabled. 1: Enabled. Bit3: MATn: Match Function Enable. This bitenables/disables the match function for PCA module n. When enabled,matches of the PCA counter with a module's capture/compare registercause the CCFn bit in PCA0MD register to be set. 0: Disabled. 1:Enabled. Bit2: TOGn: Toggle Function Enable. This bit enables/disablesthe toggle function for PCA module n. When enabled, matches of the PCAcounter with a module's capture/compare register cause the logic levelon the CEXn pin to toggle. 0: Disabled. 1: Enabled. Bit1: PWMn: PulseWidth Modulation Mode Enable. This bit enables/disables the comparatorfunction for PCA module n. When enabled, a pulse width modulated signalis output on the CEXn pin. 0: Disabled. 1: Enabled. Bit0: ECCFn:Capture/Compare Flag Interrupt Enable. This bit sets the masking of theCapture/Compare Flag (CCFn) interrupt. 0: Disable CCFn interrupts. 1:Enable a Capture/Compare Flag interrupt request when CCFn is set.

TABLE 83 PCA0L: PCA Counter/Timer Low Byte R/W R/W R/W R/W R/W R/W R/WR/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress 0xE9 Bits 7-0: PCA0L: PCA Counter/Timer Low Byte. The PCA0Lregister holds the low byte (LSB) of the 16-bit PCA Counter/Timer.

TABLE 84 PCAOH: PCA Counter/Timer High Byte R/W R/W R/W R/W R/W R/W R/WR/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xF9 Bits 7-0: PCA0H: PCA Counter/Timer High Byte. The PCA0Hregister holds the high byte (MSB) of the 16-bit PCA Counter/Timer.

TABLE 85 PCA0CPLn: PCA Capture Module Low Byte R/W R/W R/W R/W/ R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xEA-0xEE PCA0CPLn Address: PCA0CPL0 = 0xEA (n = 0) PCA0CPL1 =0xEB (n = 1) PCA0CPL2 = 0xEC (n = 2) PCA0CPL3 = 0xED (n = 3) PCA0CPL4 =0xEE (n = 4) Bits7-6: PCA0CPLn: PCA Capture Module Low Byte. ThePCA0CPLn register holds the low byte (LSB) of the 16-bit capture modulen.

TABLE 86 PCA0CPHn: PCA Capture Module High Byte R/W R/W R/W R/W R/W R/WR/W R/W Reset Value 00000000 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFRAddress: 0xFA-0xFE PCA0CPHn Address: PCA0CPH0 = 0xFA (n = 0) PCA0CPH1 =0xFB (n = 1) PCA0CPH2 = 0xFC (n = 2) PCA0CPH3 = 0xFD (n = 3) PCA0CPH4 =0xFE (n = 4) Bits7-0: PCA0CPHn: PCA Capture Module High Byte. ThePCA0CPHn register holds the high byte (MSB) of the 16-bit capture modulen.

TABLE 87 Boundary Data Register Bit Definitions Bit Action Target  0Capture Reset Enable from MCU Update Reset Enable to /RST pin  1 CaptureReset input from /RST pin Update Reset output to /RST pin  2 CaptureExternal Clock from XTAL1 pin Update Not used  3 Capture Weak pullupenable to Port pins Update Weak pullup enable from MCU  4-11 Capture SFRAddress Bus bit from CIP-51 (e.g. Bit4 = SFRA0, Bit5 = SFRA1...) UpdateSFR Address Bus bit to SFR Address Bus (e.g. Bit4 = XSFRA0, Bit5 =XSFRA1) 12-19 Capture SFR Data Bus bit read from SFR (e.g. Bit12 =SFRD0, Bit13 = SFRD1...) Update SFR Data Bus bit written to SFR (e.g.Bit 12 = SFRD0, Bit13 = SFRD1...) 20 Capture SFR Write Strobe fromCIP-51 Update SFR Write Strobe to SFR Bus 21 Capture SFR Read Strobefrom CIP-51 Update SFR Read Strobe to SFR Bus 22 Capture SFRRead/Modify/Write Strobe from CIP-51 Update SER Read/Modify/Write Strobeto SFR Bus 23, 25, 27, 29, Capture P0.n output enable from MCU (e.g.Bit23 = P0.0, Bit25 = P0.1, etc.) 31, 33, 35, 37 Update P0.n outputenable to pin (e.g. Bit23 = P0.0oe, Bit25 = P0.1oe, etc.) 24, 26, 28,30, Capture P0.n input from pin (e.g. Bit24 = P0.0, Bit26 = P0.1, etc.)32, 34, 36, 38 Update P0.n output to pin (e.g. Bit24 = P0.0, Bit26 =P0.1, etc.) 39, 41, 43, 45, Capture P1.n output enable from MCU (e.g.Bit39 = P1.0, Bit41 = P1.1, etc.) 47, 49, 51, 53 Update P1.n outputenable to pin (e.g. Bit39 = P1.0oe, Bit41 = P1.1oe, etc.) 40, 42, 44,46, Capture P1.n input from pin (e.g. Bit40 = P1.0, Bit42 = P1.1, etc.)48, 50, 52, 54 Update P1.n output to pin (e.g. Bit40 = P1.0, Bit42 =P1.1, etc.) 55, 57, 59, 61, Capture P2.n output enable from MCU (e.g.Bit55 = P2.0, Bit57 = P2.1, etc.) 63, 65, 67, 69 Update P2.n outputenable to pin (e.g. Bit55 = P2.0oe, Bit57 = P2.1oe, etc.) 56, 58, 60,62, Capture P2.n input from pin (e.g. Bit56 = P2.0, Bit58 = P2.1, etc.)64, 66, 68, 70 Update P2.n output to pin (e.g. Bit56 = P2.0, Bit58 =P2.1, etc.) 71, 73, 75, 77, Capture P3.n output enable from MCU (e.g.Bit71 = P3.0, Bit73 = P3.1, etc.) 79, 81, 83, 85 Update P3.n outputenable to pin (e.g. Bit71 = P3.0oe, Bit73 = P3.1oe, etc.) 72, 74, 76,78, Capture P3.n input from pin (e.g. Bit72 = P3.0, Bit74 = P3.1, etc.)80, 82, 84, 86 Update P3.n output to pin (e.g. Bit72 = P3.0, Bit74 =P3.1, etc.)EXTEST provides access to both capture and update actions, while Sampleonly performs a capture.

1. An integrated circuit package, comprising: a processing core foroperating on a set of instructions to carry out predefined processes; aninternal oscillator for providing a system clock for the integratedcircuit package; and an internal oscillator control register forcontrolling the operation of the internal oscillator responsive tocontrol bits of the internal oscillator controlled by the processingcore.
 2. The integrated circuit package of claim 1, wherein the internaloscillator is disabled/enabled responsive an internal oscillator enablebit set by the processing core within the internal oscillator controlregister.
 3. The integrated circuit package of claim 1, wherein anoperating frequency of the internal oscillator is set responsive tointernal oscillator frequency control bits set by the processing corewithin the internal oscillator control register.
 4. The integratedcircuit package of claim 1, further including: an external oscillatorfor providing the system clock for the integrated circuit package; andcircuitry for switching between the internal oscillator and the externaloscillator responsive to a system clock source select bit set by theprocessing core within the internal oscillator control register.
 5. Theintegrated circuit package of claim 4, wherein the circuitry forswitching further comprises a multiplexer for multiplexing between anoutput of the internal oscillator and an output of the externaloscillator to provide the system clock, said multiplexer switchingbetween the outputs responsive to the system clock source select bit. 6.The integrated circuit package of claim 4, further including an externaloscillator control register for controlling operation of the externaloscillator responsive to control bits of the external oscillatorcontrolled by the processing core.
 7. The integrated circuit package ofclaim 6, wherein an operating frequency of the external oscillator isset responsive to external oscillator frequency control bits set by theprocessing core within the external oscillator control register.
 8. Theintegrated circuit package of claim 6, wherein an operating mode of theexternal oscillator is set responsive to external oscillator modecontrol bits set by the processing core within the external oscillatorcontrol register, said operating mode establishing an external input tothe external oscillator.
 9. The integrated circuit package of claim 8,wherein the external oscillator is configured in a first mode ofoperation for receiving the external input from an external crystal viaa dual pin input.
 10. The integrated circuit package of claim 8, whereinthe external oscillator is configured in a second mode of operation forreceiving the external input from an external RC network via a singlepin input.
 11. The integrated circuit package of claim 8, wherein theexternal oscillator is configured in a third mode of operation forreceiving the external input from an external capacitor via a dual pininput.
 12. The integrated circuit package of claim 8, wherein theexternal oscillator is configured in a fourth mode of operation forreceiving the external input from an external resonator via a single pininput.
 13. An integrated circuit package, comprising: a processing corefor operating on a set of instructions to carry out predefinedprocesses; an internal oscillator for providing a system clock for theintegrated circuit package; an external oscillator for providing thesystem clock for the integrated circuit package; an internal oscillatorcontrol register for controlling the operation of the internaloscillator responsive to control bits of the internal oscillatorcontrolled by the processing core; an external oscillator controlregister for controlling operation of the external oscillator responsiveto control bits of the external oscillator controlled by the processingcore; and a multiplexer for multiplexing between an output of theinternal oscillator and an output of the external oscillator to providethe system clock, said multiplexer switching between the outputsresponsive to a system clock source select bit set by the processingcore within the internal oscillator control register.
 14. The integratedcircuit package of claim 13, wherein the internal oscillator isdisabled/enabled responsive an internal oscillator enable bit set by theprocessing core within the internal oscillator control register.
 15. Theintegrated circuit package of claim 13, wherein an operating frequencyof the internal oscillator is set responsive to internal oscillatorfrequency control bits set by the processing core within the internaloscillator control register.
 16. The integrated circuit package of claim13, wherein an operating frequency of the external oscillator is setresponsive to external oscillator frequency control bits set by theprocessing core within the external oscillator control register.
 17. Theintegrated circuit package of claim 13, wherein an operating mode of theexternal oscillator is set responsive to external oscillator modecontrol bits set by the processing core within the external oscillatorcontrol register, said operating mode establishing an external input tothe external oscillator.
 18. The integrated circuit package of claim 17,wherein the external oscillator is configured in a first mode ofoperation for receiving the external input from an external crystal viaa dual pin input.
 19. The integrated circuit package of claim 17,wherein the external oscillator is configured in a second mode ofoperation for receiving the external input from an external RC networkvia a single pin input.
 20. The integrated circuit package of claim 17,wherein the external oscillator is configured in a third mode ofoperation for receiving the external input from an external capacitorvia a dual pin input.
 21. The integrated circuit package of claim 17,wherein the external oscillator is configured in a fourth mode ofoperation for receiving the external input from an external resonatorvia a single pin input.